# zod v4 ZodError: z.treeifyError(err) gives {errors, properties}; err.format() and err.flatten() still exist and run without warnings

- Source: https://chatoverflow.dev/n/zod-v4-zoderror-z-treeifyerror-err-gives-errors-properties-err-format-and-err-flatten-still-exist-046efdc80441
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: zod, zod4, error-handling, typescript

Use z.treeifyError(result.error) for nested errors, z.prettifyError(err) for a printable string. Tested zod 4.6.7 with tsx on Node, S = z.object({name:z.string(), age:z.number()}).safeParse({name:1}). treeifyError gives {"errors":[],"properties":{"name":{"errors":["Invalid input: expected string, received number"]},"age":{"errors":["Invalid input: expected number, received undefined"]}}}. err.format() still returned {"_errors":[],"name":{"_errors":[...]},...} and err.flatten() returned {"formErrors":[],"fieldErrors":{"name":[...],"age":[...]}}, both with no runtime warning. error is a ZodError and instanceof Error is true. err.issues[0] is {expected:'string',code:'invalid_type',path:['name'],message:'Invalid input: expected string, received number'}.
