JSON to TypeScript Converter

Paste JSON, get TypeScript interfaces

The JSON is parsed locally in your browser - nothing is uploaded. Types are inferred from this one sample, so check fields that are sometimes missing or null in your real data.

Paste any JSON - an API response, a config file, a sample payload - and this free JSON to TypeScript Converter writes the TypeScript interfaces for you. Nested objects become their own named interfaces instead of anonymous inline shapes, arrays are typed from their contents (an array of objects becomes an array of a named interface), and primitives map to string, number and boolean. A JSON null becomes the null type, so a field that is null in your sample shows up as a union such as string | null when other samples merge in - check those fields first, because a single sample can only show one shape.

The naming follows the conventions TypeScript developers expect: interface names are PascalCase versions of the field names, and an array field like "items" produces an "Item" interface. If two different objects would get the same name but have different shapes, the later one is numbered (Item2) so nothing collides. An empty array is typed unknown[] because there is nothing to infer from, and an empty object becomes an index-signature interface. Everything runs locally in your browser - your JSON is never uploaded, which matters when it is a real customer or production payload.

How to use

  1. Paste your JSON into the top box (it must be valid JSON - use double quotes).
  2. Set the root interface name if you want something other than "Root".
  3. Click "Convert to TypeScript".
  4. Review the generated interfaces, especially any null or empty-array fields.
  5. Click "Copy output" and paste the interfaces into your project.

Frequently asked questions

How are nested objects handled?

Every nested object becomes its own named, exported interface, and the parent field references it by name. For example an "address" object produces an Address interface and the root gets an address: Address field. Arrays of objects work the same way, with the interface named after the singular of the field.

What does the converter do with null values?

A field whose value is null is typed as null. That is honest but often not what you want - in real data the field is usually string | null or number | null. Treat null fields as a prompt to check more samples, then widen the type by hand. Values in a mixed array of plain values and null become a union that includes null.

What happens with arrays?

The converter looks at every element. One consistent element type gives a simple array type like string[] or Item[]. Mixed elements give a union array like (string | number)[]. An empty array cannot be inferred, so it becomes unknown[] - replace it with the real element type if you know it.

Is my JSON kept private?

Yes. The conversion is done by JavaScript running in this page; your JSON never leaves your device, is not stored and is not sent to any server. That makes the tool safe for internal API responses and sample production data.

Related Tools

More free developer tools from ToolVora - every tool runs entirely in your browser, with no sign-up and no uploads: