JSON to TypeScript

Paste JSON and get strict TypeScript types—ideal for Next.js API responses and config objects.

When to use this tool

  • Deriving TypeScript types for a REST or GraphQL response you do not own.
  • Generating initial types from a config or fixture JSON.
  • Teaching — showing juniors how optional fields emerge from nullable data.

How it works

  1. Paste a representative JSON sample (keep it small but include every field variant).
  2. Choose strict or loose mode if the UI offers it.
  3. Copy the generated interfaces into your codebase.
  4. Tighten types by hand where the generator guessed unions or records.

Privacy: This tool runs entirely in your browser. Your input is not sent to our servers.

Advertisement

Frequently asked questions

Does it infer discriminated unions?

Not automatically. Combine multiple payload shapes by hand with a shared discriminant field like `type` or `kind`.

Does the output include runtime validation?

No. Pair the types with a runtime validator like zod or valibot if the API boundary is untrusted.

Will nested arrays be typed correctly?

Yes, as long as array elements share a shape. Mixed-shape arrays are inferred as unions and may need manual tightening.