JSON Formatter
Pretty-print, validate and minify JSON with friendly error messages.
Turn any JSON into a TypeScript Zod schema with nullable and optional handling.
Your result is ready — download it below:
Re-encoded without size gain Download links expire within 30 minutes.
No result to display for the current input.
Turn any JSON into a TypeScript Zod schema with nullable and optional handling.
Paste any JSON document and get a TypeScript zod schema in seconds. The generator infers every field type, wraps null values in .nullable(), marks keys missing from some array samples as .optional(), and inlines nested objects as z.object() shapes. The output exports the schema and a derived z.infer type, so it compiles the moment you paste it.
Paste a JSON document, choose a name for the exported constant, and pick how to handle unknown keys — default strips them, .strict() rejects them and .passthrough() keeps them. Press Run and the generator walks the document, building a single nested schema. Arrays become z.array(), and when an array holds objects the field sets are merged across every sample so a key absent from some entries automatically becomes .optional().
Strings map to z.string(), booleans to z.boolean(), and numbers to z.number() — refined to z.number().int() when every seen value is a whole number. A null value produces .nullable(), and anything genuinely ambiguous falls back to z.unknown() so the schema always parses.
Unlike struct generators that emit separate named types, Zod schemas are almost always written inline, so this tool inlines every nested object directly into the parent shape with matching indentation. You get one readable, self-contained schema — ideal for forms, API response validation and TypeScript end-to-end type safety via z.infer.
Fields that are null in some samples become .nullable(); fields missing from some samples of the same object become .optional(). The Unknown Keys option controls how keys that no sample contains are treated at the object level, mirroring Zod's .strict() and .passthrough() modes.
Your JSON is processed only to produce the schema and is never stored, logged or shared. There is no upload, no account and no watermark.
Yes. Run npm i zod, paste the snippet into a .ts file, and it compiles as-is — both the export const schema and the export type derived from it via z.infer.
null values become .nullable() and keys missing from some array samples become .optional(), so validation accepts exactly the shapes that appear in your data.
Default strips unknown keys, .strict() adds .strict() to every object so unknown keys fail validation, and .passthrough() adds .passthrough() so they are kept. This mirrors Zod's built-in object modes.
The fields of every object in the array are merged, so a key that appears in only some entries becomes .optional() — matching what a runtime parser will actually receive.
JSON to Zod Schema Builder converts any JSON document into a TypeScript zod schema. Objects become nested z.object()s, arrays become z.array(), numbers are refined with .int() when they are whole, and ambiguous values fall back to z.unknown().
How to use: paste some JSON, optionally name the schema and choose how unknown keys are handled (strip, .strict() or .passthrough()), then press Run. The export includes a z.infer type so the generated TypeScript compiles as-is.
z.object shapes for the whole document.nullable(); fields missing from some array samples become .optional()z.number().int()Pretty-print, validate and minify JSON with friendly error messages.
Turn any JSON into ready-to-compile Rust struct definitions with serde derives.
Convert any JSON into Go struct definitions with json tags and pointers for optionals.
Decode JWT header and payload instantly, 100% in your browser — the token never leaves your device.