JSON to TypeScript
Types, Zod schemas and structs from any JSON.
Runs in your browserRelated
About
JSON to TypeScript infers a full type definition from any JSON document — walking nested objects and arrays, marking keys optional when they're missing from some array elements, merging mixed scalar types into unions, and recognizing a repeated low-cardinality string field (like a status column) as a literal-union "enum" automatically. The same inferred schema emits as TypeScript, a Zod schema, JSON Schema, Go structs, or Python dataclasses/Pydantic models — pick a target and the code updates live. Structurally identical nested objects are deduplicated into one named type instead of being repeated. Runs entirely in your browser; nothing you paste is sent anywhere.
Frequently asked
- How does it know a field is optional?
- When a JSON array has objects with different keys, any key that's missing from at least one element is marked optional in the generated type.
- Does it detect enums automatically?
- Yes — a string field that repeats 3 or more times with 5 or fewer distinct values (like a "status" or "role" column) is inferred as a string-literal union instead of a plain string.
- Is the generated TypeScript guaranteed to actually compile?
- The type inference is tested by feeding real JSON samples through the TypeScript compiler itself and asserting zero type errors, not just by eyeballing the output.