JSON to TypeScript

Generate TypeScript interfaces from JSON

About JSON to TypeScript

JSON to TypeScript generates a single Root interface with one field per top-level JSON key, entirely in your browser — nothing is uploaded to a server. Strings, numbers, and booleans map directly to their TypeScript types; arrays are typed as any[] and nested objects as object, since nested values aren't recursively converted into their own interfaces. Field names are inserted as plain identifiers with no quoting, so a JSON key containing a hyphen or space will produce invalid TypeScript.

How to use JSON to TypeScript

  1. 1Paste your JSON into the input box.
  2. 2Click 'Convert' to generate a TypeScript interface from the top-level properties.
  3. 3Review the output and add nested interfaces by hand where needed.
  4. 4Click 'Copy' to copy the code into your project.

Frequently Asked Questions

Is JSON to TypeScript free to use?

Yes, it's completely free with no signup required.

Does it generate nested interfaces for nested JSON?

No — only top-level keys become typed fields. Nested objects are typed as object and arrays as any[], rather than generating separate nested interfaces.

What if my JSON has unusual field names, like ones with hyphens or spaces?

Field names are inserted as plain TypeScript identifiers with no quoting, so a key like "first-name" produces invalid syntax — you'll need to manually wrap such names in quotes.

Can I download the generated code as a file?

No, there's only a 'Copy' button — paste the copied code into a file yourself.

Tips & Tricks

  • For nested objects or arrays of objects, manually define additional interfaces and update the field types to reference them.
  • Rename the generated interface from Root to something more specific to your data.
  • If your JSON has field names that aren't valid identifiers (hyphens, spaces, leading digits), wrap them in quotes by hand, e.g. 'first-name': string;.
  • Review whether any fields should be optional (marked with ?) based on your actual data, since the tool always generates required fields.