JSON to TypeScript
Generate TypeScript types from JSON data.
Generate TypeScript types from JSON data.
Related tools
Ready tools are shown first.
Tool guide
Free Online JSON to TypeScript Generator
Generate TypeScript interfaces from a sample JSON object directly in your browser. The generator infers nested objects, arrays, primitive values, and mixed array types to create editable starter definitions for TypeScript projects.
Steps
How it works
- Paste a JSON object or an array whose first item is an object.
- Enter the name to use for the root TypeScript interface.
- Generate interfaces from the values present in the sample.
- Review, copy, or download the generated TypeScript file.
Highlights
Key features
- Generates exported TypeScript interfaces from sample JSON.
- Creates named interfaces for nested objects.
- Infers arrays from up to the first 10 sample items and creates union element types when needed.
- Keeps valid property identifiers and quotes property names that TypeScript cannot use directly.
- Represents JSON null values as the null type.
- Provides copy and TypeScript download actions.
Use cases
Common uses
- Create starter interfaces for API response samples.
- Model nested configuration data in a TypeScript project.
- Turn example JSON payloads into editable frontend types.
- Explore the inferred shape of unfamiliar JSON data.
Notes
Limitations to know
- The input must be sample JSON; JSON Schema input is not supported.
- Every property found in the sample is generated as required, so missing and optional fields cannot be inferred.
- A root array is inferred from its first object, while an empty root array or a primitive root is rejected.
- Empty arrays become unknown[], and mixed arrays are inferred from no more than the first 10 items.
- Date-looking values remain strings, and generated names or interfaces may need review for collisions and project conventions.
FAQ
Frequently asked questions
Does JSON to TypeScript create interfaces or type aliases?
It creates exported interfaces for the root object and nested objects.
Are nested objects and arrays supported?
Yes. Nested objects become named interfaces, and arrays are inferred from up to their first 10 items.
Are optional TypeScript properties inferred?
No. A single JSON sample cannot reveal missing fields, so properties present in the sample are generated as required.
Can I generate TypeScript from JSON Schema?
No. This tool reads sample JSON values rather than JSON Schema documents.
How are null values handled?
A sample value of null is emitted as the null type. Review it manually if the real field also accepts another type.