JSON to TypeScript API
Generate TypeScript interfaces or type aliases from a sample JSON document. Keys missing from some array items become optional.
POST /api/v1/tools/json-to-typescriptMCP json_to_typescriptDeveloper ToolsGenerate TypeScript interfaces or type aliases from JSON, with named nested types, merged array shapes, optional keys and null unions. Runs in your browser.
Input
Send these as a JSON object. Unknown fields are rejected.
- input
- A sample JSON document (object or array). (string, required)
- rootName
- Name of the top-level type. (string, up to 100 characters, default "Root")
- style
- interface emits `interface X {}`; type emits `type X = {}`. (string, one of interface, type, default "interface")
- exportKeyword
- Prefix each declaration with export. (boolean, default true)
curl https://pithlab.com/api/v1/tools/json-to-typescript \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"input":"{\"id\":1,\"title\":\"Hello\",\"author\":{\"name\":\"Ada\"},\"tags\":[\"intro\"]}","rootName":"Post"}'Example response
{
"ok": true,
"result": {
"output": "interface Post {\n id: number;\n title: string;\n author: Author;\n tags: string[];\n}\n\ninterface Author {\n name: string;\n}\n"
}
}