Format, validate, and minify JSON with syntax highlighting.
Open toolJSON to TypeScript
Generate TypeScript interfaces from a JSON sample, with nested types.
Generated interfaces will appear hereWhat is a json to typescript?
This tool generates TypeScript interfaces directly from a JSON sample - no more hand-writing types after copying an API response. Nested objects become their own named interfaces, arrays of objects are detected and typed automatically, and fields missing from some array items are marked optional.
How to use this tool
- 1Paste a representative JSON sample, or upload a .json file.
- 2Set a root interface name (defaults to RootObject).
- 3Click Generate - nested objects and array item shapes each get their own interface.
- 4Copy the result or download it as a .ts file to drop straight into your project.
Common use cases
Frequently asked questions
How are nested objects named?
Each nested object is named after its key, converted to PascalCase (e.g. a "dimensions" field becomes an interface called Dimensions). Naming collisions are automatically resolved by appending a number.
How does it handle arrays of objects with different fields?
It merges the fields seen across every item in the array. Any field that isn't present on every item is marked optional with a `?`, rather than guessing incorrectly.
What about arrays of mixed types?
An array containing, say, numbers and strings becomes a union array type like `(number | string)[]`, which accurately reflects what's actually in the data.
Does this replace a tool like quicktype?
It covers the most common case - one JSON sample to one set of interfaces - entirely client-side. For more advanced inference across multiple samples or other target languages, a dedicated tool like quicktype may go further.
{
"runs_in_browser": true,
"data_sent_to_server": false,
"signup_required": false,
"price": "free",
"category": "JSON Tools"
}