JSON to TypeScript
Infer interfaces from JSON. Nested objects, array unions, null, and optional fields.
Added 2026-10-23
What it does
JSON to TypeScript writes an interface or a type alias from one JSON sample. Nested objects become nested types. Objects inside an array are merged, and a field that is missing from some items becomes optional. null stays in the type instead of being dropped. You can choose the root name, export, and readonly. A number bigger than Number.MAX_SAFE_INTEGER is still typed as number, with a comment, because extra digits in the sample are not a TypeScript bigint unless the JSON stores them as a string. The result describes this sample only. A field that is a string here may be a number in production. Nothing is uploaded.
How to use it
- Paste JSON. The converter does not upload it.
- Pick interface or type, the root name, export, readonly, and how optional fields are chosen.
- Objects in an array are merged. A field missing from some items becomes optional. Integers past the safe range stay number, with a comment.
Common mistakes
- This is a sample, not a schema. Types come from the values you pasted. A field that happens to be a string here may hold another type in real data.
- Large integers. A number bigger than Number.MAX_SAFE_INTEGER is still typed as number. The comment marks where precision would be lost in JavaScript.
Inference stays in this tab. The JSON is not uploaded.
Related guides
- A JSON sample is not a schema
A schema generated from one sample describes that sample. Validation checks a document, and remote $ref is not loaded.