JSON to TypeScript API
Turn any JSON payload into TypeScript interfaces online. Merges array item shapes, marks missing keys optional and dedupes identical structures. Free, no sign-up.
The JSON to TypeScript is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/json-to-typescript — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
json | string | required | The JSON document to generate TypeScript types for (max 5 MB). |
rootName | string | required | Name for the root interface or type alias. Sanitized to PascalCase and must form a valid TypeScript identifier. |
exportKeyword | boolean | required | Prefix every declaration with the export keyword. |
optionalWhenMissing | boolean | required | Mark fields missing from some array items as optional (?). When false, they stay required with undefined added to the type union. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
typescript | string | required | The generated TypeScript declarations. |
interfaceCount | number | required | Number of named interfaces emitted (excludes a root type alias). |
Example request
curl -X POST https://dot.tools/api/tools/json-to-typescript \
-H 'Content-Type: application/json' \
-d '{
"json": "{\n \"name\": \"Ada Lovelace\",\n \"active\": true,\n \"level\": 9,\n \"address\": {\n \"city\": \"London\",\n \"zip\": \"EC1\"\n },\n \"roles\": [\n \"engineer\",\n \"mathematician\"\n ],\n \"projects\": [\n {\n \"title\": \"Analytical Engine\",\n \"year\": 1843\n },\n {\n \"title\": \"Notes on the Engine\",\n \"year\": 1843,\n \"published\": true\n }\n ]\n}",
"rootName": "Biography",
"exportKeyword": true,
"optionalWhenMissing": true
}'Sample response
{
"ok": true,
"result": {
"typescript": "export interface Biography {\n name: string;\n active: boolean;\n level: number;\n address: BiographyAddress;\n roles: string[];\n projects: BiographyProjectsItem[];\n}\n\nexport interface BiographyAddress {\n city: string;\n zip: string;\n}\n\nexport interface BiographyProjectsItem {\n title: string;\n year: number;\n published?: boolean;\n}",
"interfaceCount": 3
}
}Use the free JSON to TypeScript in your browser, read the JSON to TypeScript guide, or import the full OpenAPI specification.