An optional key
trusted appears in one session, so it becomes trusted: z.boolean().optional().
{"sessions": [{"device": "a"}, {"device": "b", "trusted": true}]}Paste a JSON sample. A Zod schema and its type are written beside it.
The schema is as strict as the sample. Loosen it where real data varies, such as a string field that can also be empty.
Ctrl+Enter or ⌘+Enter runs this tool immediately.
Waiting for input.
Parsing stays in this browser. Input is not uploaded or saved.
trusted appears in one session, so it becomes trusted: z.boolean().optional().
{"sessions": [{"device": "a"}, {"device": "b", "trusted": true}]}An array of numbers and null becomes z.array(z.number().int().nullable()).
{"scores": [3, null, 5]}Generate TypeScript interfaces from a JSON sample in the browser. Array items are merged, and keys missing from some items become optional.
Generate a draft 2020-12 JSON Schema from a JSON sample in the browser. Types, nested objects, array items, and required keys are inferred.
Check a JSON document against a JSON Schema in the browser. Draft-07 and 2020-12 are supported, and remote $ref values are not fetched.