Skip to content
Zesona
JSON to TypeScript InterfaceLocal

JSON to TypeScript Interface

Generate TypeScript interfaces from a JSON sample, marking inferred optionals and unions honestly.

  • Free
  • No sign-up
  • Runs in your browser

Input

Runs in your browser

0 characters

Processed entirely in your browser. Nothing is uploaded.

Try an example

Fill in Input to continue.

Enter your input to see the result

Everything happens on this device. No upload, no account, no network request.

How to use this tool

  1. 1

    Paste your JSON into the box.

  2. 2

    A syntax error is reported with its line and column, an excerpt with a caret, and the likely cause - a trailing comma, single quotes, an unquoted key or a comment.

  3. 3

    Copy or download the result.

Questions about JSON to TypeScript Interface

Can I trust the generated types?

Treat them as a head start, not a contract. A sample is not a schema: a field absent from your sample cannot appear in the output, a field that happened to be null has an unknowable type, and an empty array says nothing about its elements. The generator says so in a header comment and lists every inference it was unsure about.

How does it handle an array of objects?

It unifies every element rather than using the first. A field present in only some of them is marked optional, and a field with different types across elements becomes a union - both reported as warnings so you know an inference was made.

Why does it report duplicate keys?

Because nothing else does. `JSON.parse({"a":1,"a":2})` silently gives `{a: 2}` - the first value vanishes with no error. In a configuration file that is a genuinely hard bug to find, so the duplicate is detected in the source text and reported.

Is my data sent anywhere?

No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.

Does the JSON to TypeScript Interface work offline?

Yes. Once the page has loaded it runs entirely as JavaScript on your own device, so the JSON to TypeScript Interface keeps working with the network switched off and nothing is ever sent to a server.

Other tools you might reach for next.