How to use the JSON to TypeScript
- Paste a representative JSON sample.
- Name the root type.
- Copy the generated interfaces into your code.
What does this tool do?
Nested objects get their own named interfaces. For arrays of objects, all items are merged — a key that's missing from some items becomes optional — so the types reflect the real variety in your data.
Generated types are only as good as the sample, so use a response that includes optional fields where possible.
Why use it?
- Type API responses in seconds.
- Avoid hand-typing large interfaces.
- Optional keys detected automatically.
Example
{"id":1,"tags":["a"]} becomes:
export interface Root {
id: number;
tags: string[];
}Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Last reviewed by the M2Toolkit team.