Productivity and Utilities

JSON to TypeScript Interface Generator

Turn a JSON sample into TypeScript types you can paste into your code.

Paste an example of the data. It is read in this tab and nothing is uploaded. Up to 2,000,000 characters.

Types are guessed from the sample, so a value that is a number here may be a string or null elsewhere. All numbers become number, and an empty array becomes unknown[]. Review the result before you use it. Everything runs in your browser.

Next step

How to use the json to typescript interface generator

  1. Paste a JSON sample into the first box. It is checked as you type, with the line and column of any mistake.
  2. Set the name of the main type and choose whether to write interfaces or type aliases.
  3. Choose whether keys that are missing from some objects should be marked optional, and whether to add export or readonly.
  4. Copy the TypeScript or download it as types.ts, then check it against your real data.

How the types are chosen

Strings, numbers and booleans map to string, number and boolean, and null maps to null. All JSON numbers become number, because JSON does not separate integers from decimals in TypeScript. Arrays become T[], and an array that holds more than one type becomes a union such as (number | string | null)[]. An empty array becomes unknown[], because the sample shows nothing about its contents.

Nested objects get their own named types, named after the key: an "address" key becomes Address. Objects inside arrays get the key name followed by Item, so "orders" gives OrdersItem. If two objects have exactly the same shape they share one type, and if names clash a number is added.

Optional keys and unions

When a list holds several objects, the tool merges them. A key that some objects lack gets a question mark, so { sku: string; qty?: number }. If a key holds null in one object and a string in another, the type is string | null. Keys that are not valid names, such as "first name" or "9lives", are written in quotes.

Types made from one sample are only as complete as the sample. Paste an array with several examples to capture variation. Related tools are the JSON schema generator, the JSON formatter and validator and the CSV to JSON converter.

Privacy and limits

The conversion runs in your browser and the text is never uploaded or executed. It accepts up to 2,000,000 characters, and extremely deep nesting is cut off so the page stays responsive. The generated code is plain text for you to review before it goes into a project.

Assumptions and limits

  • Types are inferred from the sample only. Real data may have other shapes.
  • Every JSON number becomes number in TypeScript.
  • Objects with the same keys and types share a single named type.
  • The tool writes declarations only and does not validate data at run time.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

How do I convert JSON to a TypeScript interface?

Paste the JSON into the box. The tool writes an interface for the main object and one for each nested object, using the key names.

Why is a property marked optional?

Because it was missing from at least one of the objects in the sample. Turn off the option to mark every property as required.

What does unknown[] mean?

The sample had an empty array, so the tool cannot tell what the items are. Replace unknown with the real type.

Should I use interface or type?

Both describe object shapes. Interfaces can be extended and merged, and type aliases can also name unions and other forms. Pick what your codebase uses.

Does this check my data at run time?

No. TypeScript types disappear when the code is compiled, so use a validator with a schema if you need to check real data.