JSON to TypeScript
The JSON to TypeScript converter reads a sample payload and generates matching interfaces, naming nested objects after the keys that hold them. Mixed arrays produce a union of their element types rather than being typed from the first item alone, so the result describes the sample honestly.
Your result will appear here.
Not sure where to start? Use Load example.
Results update automatically and are calculated on your device. Nothing you type is sent to a server.
Runs in your browser. Processing happens entirely in your browser. Nothing you enter is sent to Delimiter.live.
How to use the JSON to TypeScript
- Paste a representative JSON payload — one that includes every field you care about.
- Give the root interface a name that matches what the payload represents.
- Read the generated interfaces; nested objects are named after the key that holds them.
- Copy or download the result into your project.
Example
{"id": 1, "tags": ["a"]}
export interface Root {
id: number;
tags: string[];
}
Common use cases
- Typing a third-party API response that has no published types.
- Turning a saved fixture into interfaces for a test suite.
- Bootstrapping types for a configuration file before hand-editing them.
- Checking how a payload would be typed before committing to a shape.
Limitations and things to watch for
- Types are inferred from one sample. A field that is absent from your sample cannot be inferred, and a field that happens to be null in the sample cannot be typed beyond null — supply a representative payload.
- Every number becomes number. TypeScript has no integer type, so there is no distinction to preserve.
- Optional fields cannot be detected from a single object. If your API omits keys rather than sending null, mark those fields optional yourself.
- Dates arrive as strings in JSON, so a date field is typed string rather than Date.