JSON & Data/JSON to TypeScript
JSON to TypeScript Interface Generator
Paste a JSON sample and instantly get TypeScript interfaces with nested types, optional fields, and union types for mixed arrays. Nothing leaves your browser.
🔒All processing happens in your browser. Nothing leaves your device.
What this does?
When you receive a JSON payload from an API or a config file, turning it into typed TypeScript code by hand is tedious and error-prone. This tool inspects every field in your JSON sample and generates a set of export interface declarations that match the shape exactly.
Nullable fields (whose value is null in the sample) are emitted as optional (field?: type). Arrays are typed from all the element shapes found in the sample — if the array holds both strings and numbers you get Array<string | number>. Nested objects each become their own named interface derived from the property key.
The generated interfaces are a starting point. Because the inference is based on a single sample, fields that can be null at runtime but aren't in your sample won't be marked optional. Always review the output before committing it.
FAQ
Is my JSON sent to a server?
No. Parsing and interface generation both happen entirely in your browser using built-in JavaScript. Nothing is transmitted anywhere.
Is there a size limit?
File uploads are capped at 20 MB. The interface generator itself works on the parsed object in memory and is very fast even for large payloads.
Why are some fields typed as null?
When a field's value is null in your sample, the tool cannot infer the real type — it only knows the field can be null. Change those manually to string | null or whatever type is correct for your API.
Does it handle arrays of mixed types?
Yes. If an array contains both strings and numbers the type will be (string | number)[]. Arrays of objects generate a shared interface for the array element shape.
Need to format or validate the JSON first? Try the JSON Formatter & Validator →