JSON to TypeScript
Paste a JSON sample and get matching TypeScript interfaces or type aliases — with named nested objects, inferred array types and optional fields. Everything runs in your browser; your data is never sent anywhere and nothing is stored.
How to use the JSON to TypeScript converter
- Paste a representative JSON sample — a real API response works best.
- Set the root name for the top-level type and choose Interface or Type alias.
- Optionally mark
nullkeys as optional, then copy the generated TypeScript.
Primitives map directly: text becomes string, numbers become number, booleans become
boolean and null becomes null. Nested objects get their own
PascalCase interface, arrays become T[], and keys that are not valid identifiers stay quoted.
More PAYATE tools
Frequently asked questions
What does this JSON to TypeScript converter do?
It reads a JSON sample and generates matching TypeScript interfaces (or type aliases). It walks every object, names nested objects in PascalCase from their keys, infers array element types as T[], and maps primitives to string, number, boolean and null — giving you ready-to-paste types.
How are nested objects and arrays handled?
Each nested object becomes its own interface, named from its key in PascalCase. Arrays are typed from their items as T[]: an array of objects reuses that item interface, an empty array becomes any[], and a mixed array becomes a union such as (string | number)[].
What is the difference between interface and type alias?
Both describe the same shape. An interface is declared with interface Name { ... } and can be extended or merged, while a type alias uses type Name = { ... }. Pick whichever matches your codebase style — the generated fields are identical.
What does the "optional for null" option do?
When enabled, any key whose value is null in the sample is emitted as an optional property with a ? (for example name?: null). It is handy when null simply means the field may be missing. Leave it off to keep every property required.
Is my JSON sent anywhere?
No. Parsing and generation run entirely in your browser — your JSON is never uploaded to a server and nothing is stored. It is safe for sample payloads you would not want to transmit.
Why did I get a JSON parse error?
The input must be valid JSON: keys and strings in double quotes, no trailing commas, and no comments. The error message shows what the browser parser rejected — fix that spot, or paste a real response, and the TypeScript regenerates live.