How to use it
- 1Paste your JSON or drop a file onto the input panel.
- 2Adjust the options — the result updates as you type.
- 3Copy the TypeScript or download it. Drop several files to convert a batch into one ZIP.
How types are inferred
Every element of an array is inspected, not just the first. A key that is missing from some elements becomes optional (coupon?: string), and a key that is sometimes null becomes a union (string | null) — the two cases a single-sample generator gets wrong.
Nested objects get their own named interface, taken from the key and singularised for arrays: subscriptions: Subscription[]. Integers and decimals are both number, as they are in JavaScript.
Questions
A field is null in my sample. What type does it get?
null on its own, because the sample holds no other evidence. Paste a response where the field has a value, or edit the type by hand.
Should I use interface or type?
Either works for object shapes. Interfaces give clearer error messages and can be extended; type aliases are needed for unions. The option switches between them.