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.

Free · No installationYour text and JSON are processed only in this browser.

Input: up to 2 MiB and 10,000 lines. Output: up to 4 MiB. Changing inputs hides the previous result.

How to use

  1. Paste a valid JSON object, array or primitive value.
  2. Choose an ASCII type name and whether to add export.
  3. 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.

Related tools

Processing references