JSON to TypeScript Generator
A sample-derived draft, not a schema or runtime validator. Container arrays use only the first item; later items may differ. Primitive-only arrays produce a deduplicated union; empty arrays become unknown[].
A sample-derived draft, not a schema or runtime validator. Container arrays use only the first item; later items may differ. Primitive-only arrays produce a deduplicated union; empty arrays become unknown[].
Paste JSON and generate.
A primitive or array root uses a type alias even when interface mode is selected.
Null remains the null type; only the null-optional or all-optional option adds ?. Date detection checks only a YYYY-MM-DD prefix, not calendar validity, and does not convert JSON strings at runtime. Literals apply to strings shorter than 30 characters and finite numbers. All keys are quoted; camel case changes the declared names, not the JSON data.
Reserved root names receive a Type suffix. Nested names are allocated uniquely and deterministically. Output is plain text, never evaluated or compiled; input is not uploaded or stored.
Invalid JSON or limit exceeded: input 100,000 characters, depth 30, nodes 10,000, generated output 200,000 characters. Root name: 1–64 ASCII identifier characters, starting with a letter, _ or $. Nonfinite numbers are rejected.
A QUICK WALKTHROUGH
How to use this tool
- Paste one JSON sample and enter a bounded root identifier.
- Choose interface or alias and the inference options.
- Generate, review sampling limitations, and copy the text.
Declaration style
A primitive or array root uses a type alias even when interface mode is selected.
Generate types
Null remains the null type; only the null-optional or all-optional option adds ?. Date detection checks only a YYYY-MM-DD prefix, not calendar validity, and does not convert JSON strings at runtime. Literals apply to strings shorter than 30 characters and finite numbers. All keys are quoted; camel case changes the declared names, not the JSON data.
Root type name
Reserved root names receive a Type suffix. Nested names are allocated uniquely and deterministically. Output is plain text, never evaluated or compiled; input is not uploaded or stored. Invalid JSON or limit exceeded: input 100,000 characters, depth 30, nodes 10,000, generated output 200,000 characters. Root name: 1–64 ASCII identifier characters, starting with a letter, _ or $. Nonfinite numbers are rejected.
GOOD TO KNOW
Common questions
Are these types a complete schema?
No. They describe the selected sample and options. Missing fields and different array items are not discovered.