How do I convert JSON to TypeScript?
Paste a JSON sample and this tool generates matching TypeScript interfaces. Objects become named interfaces, nested objects get their own interfaces, arrays are typed from all their elements, and keys missing from some records are marked optional. Everything runs in your browser and nothing is uploaded.
Turn a JSON sample into TypeScript types
Writing TypeScript interfaces by hand from an API response is slow and easy to get wrong. This tool reads a JSON sample and generates the matching interfaces for you: paste the JSON, give the top-level interface a name, and the typed version appears straight away. It is built for the everyday job of typing a fetch result, a config file or a webhook payload so your editor can help you rather than guess.
Each object becomes an interface, and any object nested inside it becomes its own interface named in PascalCase from the key it sits under. Arrays are typed from their contents, primitives map to string, number and boolean, and a null value is kept in the type as part of a union. Everything runs in your browser, so a real response you would never paste into an unknown site stays on your device.
How arrays and optional keys are inferred
Arrays are where a sample tells you the most and the least at once. The tool looks at every element, not just the first, and builds the element type from all of them. When an array holds objects, the keys are merged across every element: a key that appears in some records but not others cannot be guaranteed, so it is marked optional with a question mark. When elements are a mix of types, you get a union such as (string | number)[].
Why generated types are a starting point
A sample describes the data you happened to have, not every response the server can send, so treat the output as a strong first draft and tighten it against your API documentation. Three things are worth checking every time. Optional fields: if a key is always present in your sample it will not be marked optional, even though the real API might sometimes omit it. Unions: a field that is a number in your sample might be a string elsewhere, and only a wider sample would reveal that. Dates: JSON has no date type, so a value like "2026-09-06" is reported as string, and you may want to change it to Date yourself.
Empty values cannot be typed from nothing. An empty array becomes unknown[] and an empty object becomes Record<string, unknown>, both safe placeholders you can replace once you have a sample that actually contains data. A null on its own is typed as null, which usually means you want to widen it, for example to string | null, once you know the populated shape.
Private, and useful with real data
Because the conversion happens entirely in your browser with the built-in JSON parser, nothing is uploaded, logged or sent anywhere. That is the point: you can drop in a genuine payload from your own backend, complete with names, ids and internal fields, and know it never leaves the machine you are on. If the JSON will not parse, you get a clear message with the position of the problem, which is usually a trailing comma, a single quote where a double quote is needed, or an unquoted key. Fix that one spot and the types appear.
How we work it out
The sample is parsed with JSON.parse, then each value is mapped to a TypeScript type: objects to interfaces (named in PascalCase from their key), arrays to element-type arrays with keys merged across elements, and null folded into a union such as string | null. Empty arrays become unknown[] and empty objects become Record<string, unknown>.
Frequently asked questions
Is my JSON uploaded anywhere?
No. The sample is parsed and converted entirely in your browser with JavaScript. Your data never leaves your device, which makes it safe to use with real API responses and config files you would not paste into an unknown website.
Why are some keys marked optional with a question mark?
When the tool sees an array of objects, it merges the keys from every element. If a key is present in some elements but missing from others, it cannot be guaranteed, so it is marked optional. That reflects the sample you gave, which may not match the true shape of the data.
Why is a date shown as a string?
JSON has no date type, so dates are stored as strings such as 2026-09-06. The tool can only type what it sees, so it reports string. If a field is really a date, change it to Date yourself, or keep it as a string and parse it in your code.
Are the generated types guaranteed to be correct?
They are a faithful description of the sample, not of every possible response. A single sample cannot show every optional field, every union member or the difference between an empty and a populated array. Treat the output as a strong starting point and refine it against your API documentation.
What happens with an empty array or empty object?
An empty array becomes unknown[] because there is no element to infer a type from, and an empty object becomes Record<string, unknown>. Both are safe placeholders you can tighten once you have a sample that contains data.