🔷 JSON to TypeScript

Paste JSON and get TypeScript interfaces generated instantly.

About JSON to TypeScript

Convert a JSON object into TypeScript interface or type declarations. Nested objects become named types, arrays are inferred from their elements, and optional fields are detected automatically.

How to use

  1. Paste a JSON object into the input.
  2. Pick interface or type from the toggle.
  3. Adjust the root name if you want a specific identifier.
  4. Copy the generated TypeScript and drop it into your project.

Common use cases

  • Quickly typing a third-party API response without writing the shape by hand.
  • Bootstrapping types from a representative fixture.
  • Converting documentation examples into compilable types.
  • Sharing a typed contract derived from a real backend response.

Tips

  • Fields missing from any array element are emitted as optional (?:).
  • Mixed-type arrays produce a union, e.g. (string | number)[].
  • Deeply nested shapes flatten into a clean list of named interfaces.

FAQ

Should I use interface or type?
Either — toggle in the UI. Interfaces are easier to extend; type aliases compose better via unions and intersections.
Why are some fields marked optional (?:)?
If a field is missing in any element of an array, the generator marks it optional so the resulting type matches every element.
How are mixed-type arrays handled?
They're emitted as a union — for example, an array containing strings and numbers becomes (string | number)[].
Does it handle deeply nested objects?
Yes. Nested objects are flattened into a list of named interfaces so the output stays readable instead of one massive type.

More tools

JSON

Code

Ornaments

Image

Audio

Web / SEO

Generators

PDF

Time