jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON → TypeScript

interfaces or types · readonly · optional from multiple samples

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

  1. Paste your JSON sample (or multiple — + Add example generalizes across them).
  2. Configure:
    • Output: interface or type.
    • 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.
  3. 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.