JSON to TypeScript Interface Generator

JSON Input
1
Root Name
TypeScript Output

Last updated:

Jsonic's JSON to TypeScript converter generates TypeScript interfaces from any JSON object. It infers types for strings, numbers, booleans, arrays, and nested objects. Nullable fields (null values) are typed as string | null. Arrays of mixed types produce union types. Deeply nested objects generate separate named interfaces. Paste your JSON and click Generate — no server involved.

How to convert JSON to TypeScript

  1. Paste your JSON object into the left panel.
  2. Click Generate to produce TypeScript interfaces.
  3. The root interface is named Root by default.
  4. Nested objects become separate named interfaces.
  5. Copy or download the result.

FAQ

How are nullable fields handled?

Fields with a null value are typed as string | null (or the inferred type | null). If you want stricter types, edit the JSON sample to include a non-null example.

How are arrays typed?

Arrays of primitives become typed arrays (e.g. string[]). Arrays of objects become interface arrays (e.g. Item[]). Mixed-type arrays become union arrays (e.g. (string | number)[]).

Can I rename the root interface?

Not yet — the root is always named Root. Rename it manually in the output after copying.

Does this send my JSON to a server?

No. The TypeScript generation runs entirely in your browser.

How are deeply nested objects handled?

Each nested object level generates its own named interface. For example, a "address" object inside "user" produces an Address interface that is referenced in the User interface.

What if my JSON has inconsistent array item types?

If array items have different shapes, the generator produces a union type covering all observed shapes.

Can I use this output directly in a TypeScript project?

Yes. Copy the output and paste it into a .ts or .d.ts file. You may want to rename Root to a more descriptive name.