Category: Developer tools
JSON to TypeScript
Turn a JSON document into TypeScript interfaces
Paste a JSON document and get back TypeScript interface declarations inferred from its shape, with nested objects broken out into their own named interfaces. Runs entirely in your browser.
interface RootAddress {
city: string;
country: string;
}
interface Root {
id: number;
name: string;
isActive: boolean;
tags: string[];
address: RootAddress;
}
Everything on this page is processed in your browser. Nothing is uploaded.
Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
Typing a payload by hand is tedious and easy to get subtly wrong, especially once objects nest a few levels deep. This tool walks a parsed JSON document and, for every object it finds, generates a named interface with a property for each key and its inferred type, recursing into nested objects and arrays. Arrays of mixed primitive types become a union; arrays of objects generate their own interface. The result is a starting point to refine, not a guarantee of the server's real contract, since JSON alone can't distinguish optional fields from ones that happened to be present in this sample.
How to use it
- Paste a JSON document, or load the example.
- Set a name for the root type.
- Copy the generated TypeScript interfaces.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- Is my JSON uploaded anywhere?
- No. Parsing and type inference happen in JavaScript running in the page, so your data never leaves your device.
- Does it know which fields are actually optional?
- No. It can only see the one sample you paste, so every field is generated as required; add `?` by hand for fields that are sometimes absent.
- What happens with an empty array?
- Since there's no element to infer a type from, an empty array becomes unknown[]; replace it with the real element type once you know it.