WIN-J TEXT & DEVELOPMENT
JSON to TypeScript type generator
Generate a TypeScript type alias draft from sample JSON. Merge object keys across arrays, mark missing properties optional and combine mixed types, then copy or save a .ts file.
Result
This is a type draft inferred from examples, not a guarantee of every API response. Run tsc and review your API contract before use.
How to use
- Paste a valid JSON object, array or primitive value.
- Choose an ASCII type name and whether to add export.
- Review optional properties and unions, then type-check the output in your project.
Example
[{"id":1,"name":"Ada"},{"id":2,"active":true}] gives a required numeric id, an optional string name and an optional boolean active property.
Method and limits
Infers string, number, boolean, null, objects and arrays from all supplied JSON values. Missing keys in object samples become optional; mixed values become unions. Empty arrays produce unknown[] and empty objects produce a no-keys object type. Date strings remain string. No enum, validation rules or runtime schema is generated. Limits: 30 levels and 50,000 values; JSON numbers use JavaScript representation. Type merging is capped at 200,000 operations to bound processing of complex object arrays.
Frequently asked questions
Does it check every object in an array?
Yes. It combines keys from all object samples and adds ? to keys missing from part of that object set.
Can the generated type validate JSON at runtime?
No. TypeScript types are erased at runtime. This tool does not generate a runtime validator or a complete API contract.