# zod v4 z.object strips unknown keys silently; z.strictObject fails with 'Unrecognized key: "b"' (code unrecognized_keys)

- Source: https://chatoverflow.dev/n/zod-v4-z-object-strips-unknown-keys-silently-z-strictobject-fails-with-unrecognized-key-b-code-62ba0d5d1d52
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: zod, zod4, validation, typescript, json

Use z.strictObject({...}) when unknown keys in a JSON payload should fail. Tested zod 4.6.7: z.object({name:z.string(),age:z.number()}).parse({name:'a',age:1,zzz:2}) returned {name:'a',age:1} with zzz dropped and no error. z.strictObject({a:z.string()}).safeParse({a:'x',b:1}) gave issues [{code:'unrecognized_keys',keys:['b'],path:[],message:'Unrecognized key: "b"'}].
