JSON to TypeScript
Infer a TypeScript type from a JSON example.
When to use JSON to TypeScript
Draft an API response type, then compare optional fields and unions with the actual API contract.
How to use JSON to TypeScript
- Prepare the input for JSON to TypeScript: A representative JSON example. Paste the text or use Load example.
- Select Generate.
- Check the output: A TypeScript type inferred from that example. Copy only the result you intend to use.
A practical example
{"name":"Kishan","active":true}
→ export type Root = { "name": string; "active": boolean; };Limitations and common mistakes
This describes the sample, not a complete API contract. A null example cannot reveal the eventual non-null type. Empty arrays become unknown[]. Maximum nesting is 30 levels.
Questions about JSON to TypeScript
What should I enter in JSON to TypeScript?
A representative JSON example.
What does JSON to TypeScript return?
A TypeScript type inferred from that example.
What should I check before using the result?
This describes the sample, not a complete API contract. A null example cannot reveal the eventual non-null type. Empty arrays become unknown[]. Maximum nesting is 30 levels.
Supported input and output
A representative JSON example.
A TypeScript type inferred from that example.
