JSON → TypeScript
Paste a JSON sample, get TypeScript. Pick interface or type, name the top-level type, and add optional Zod output. For multi-sample optional inference and richer customisation, run schema-generator first then schema-to-types.
Paste JSON.
How to generate TypeScript
- Paste your JSON sample (or multiple — + Add example generalizes across them).
- Configure:
- Output:
interfaceortype. - Top-level name (default
Root). - Readonly properties — on / off.
- Optional vs union with undefined — pick one style.
- Also generate Zod — adds a Zod schema below the types.
- Output:
- Output appears with syntax highlighting. Copy or Download as
.ts.
FAQ
Why are all fields required?
One sample makes everything required. To mark fields as optional, provide a second sample where they're missing — the inferred type becomes field?: T.
What about union types?
For heterogeneous arrays the tool emits a union: (string | number)[]. If the variation is structural (different object shapes), consider modelling explicitly.
Will it work offline?
Yes — inference runs locally.