JSON to Zod converter
Convert JSON to Zod 4 schemas that validate data with the same shape at runtime, with named schemas for nested objects.
What you get
- Generate a Zod schema from JSON in one paste, with a named schema for every nested object.
- Your JSON is checked to pass the schema, and the schema is tested against a reference validator.
- Zod 4 output with inferred TypeScript types.
- Get a Zod schema from an API response in one paste, with exported types for every object.
- Private and free: everything runs in your browser, nothing is uploaded, and there is no sign-up.
How each result is checked
- The generated code is run with Zod 4.
- Your JSON is parsed with the generated schema. It must pass.
- The schema agrees with a reference JSON Schema validator (Ajv) on a set of valid and broken test values.
What can't convert exactly
- The schema describes what the sample shows: whole numbers become integers, and keys present in every record are required. Review it before using it for strict validation.
- Format checks (email, date-time…) are off by default, so a sample value that only looks like an email does not make the field stricter than intended.
Questions
Are unknown keys rejected?
No. Objects keep extra keys (z.looseObject), because one sample cannot show which keys are forbidden.
How do I get optional fields?
Paste an array of several records. Keys missing from some records become optional.
Does it add email or URL validation automatically?
Not by default: a sample value that only looks like an email should not make the field stricter than you meant. Turn on "Check formats" to add email, UUID and date-time checks where the sample matches them.
How do I turn an API response into a Zod schema?
Paste the JSON response here: you get a Zod schema from the API response with an exported TypeScript type (z.infer) for each object, ready for runtime validation with Root.parse(data) (Root is the default name; change it in the options).
How do I convert JSON to Zod online?
Paste your JSON or open a file on the left (or click Example). The Zod appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.
Can the Zod output be wrong?
Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.