JSON to TypeScript
Infer interfaces from any JSON payload.
How inference works
The generator walks your JSON and derives a named interface per object level: numbers become number, strings string, booleans boolean, nulls null (wrapped in a union with the sibling type when mixed), arrays take the type of their elements, and nested objects become their own interfaces with PascalCase names derived from the key. Mixed-type arrays produce union types like (string | number)[].
Two practical tips: the root interface is named Root unless the payload has a wrapper object — rename it to match your domain (User, Invoice). And since JSON only shows one snapshot, treat optional-looking fields (nulls) as nullable unions rather than adding ? blindly — a null today means the field exists but can be absent of value.
FAQ
Why did my array of different objects produce a union?
When array elements have different shapes, the safest inference is a union of interfaces. Consolidate manually if you know all variants share optional fields — or normalize your API to emit consistent shapes.
Can I get type aliases or zod schemas instead?
This tool targets plain interfaces, the most portable output. For runtime validation, paste the interfaces into a zod codegen or write the schema by hand against the inferred shape.