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

FieldTypeRequiredDescription
jsonstringrequiredThe JSON document to generate TypeScript types for (max 5 MB).
rootNamestringrequiredName for the root interface or type alias. Sanitized to PascalCase and must form a valid TypeScript identifier.
exportKeywordbooleanrequiredPrefix every declaration with the export keyword.
optionalWhenMissingbooleanrequiredMark fields missing from some array items as optional (?). When false, they stay required with undefined added to the type union.

Response

FieldTypeRequiredDescription
typescriptstringrequiredThe generated TypeScript declarations.
interfaceCountnumberrequiredNumber 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.