JSON to TypeScript: Instant Interface Generation
Manually writing TypeScript interfaces for API responses is tedious and error-prone. Paste your JSON and get a typed interface instantly — ready to paste into your codebase as a starting point. The generator handles nested objects, typed arrays, union types, and null values.
Frequently Asked Questions
How are arrays typed?
Arrays are typed from their first element. `["a","b"]` becomes `string[]`. Mixed arrays like `[1,"a"]` become `(number | string)[]`. Empty arrays become `unknown[]`.
What does null become?
JSON null becomes the TypeScript `null` literal type. If a field can be null or a string, consider adding `| undefined` manually.
Are nested objects typed inline or as separate interfaces?
Nested objects are typed inline as anonymous object types. For cleaner code, extract them manually into named interfaces.
How are numbers typed?
All JSON numbers become `number`. TypeScript does not distinguish between integers and floats — both are `number`.
What about keys with special characters?
Keys containing non-identifier characters (spaces, hyphens, etc.) are wrapped in quotes in the generated interface.
Can I use this for API response typing?
Yes — paste a real API response JSON and the generated interface gives you a starting point. Review optional fields (add ?) and refine union types as needed for production use.