JSON → TypeScript
Turn any JSON sample into TypeScript interfaces — handles nested objects, arrays of varying shape, and optional fields.
TypeScript
interface Specs {
weight_g: number;
battery_hours: number;
}
interface Review {
user: string;
stars: number;
comment?: string;
}
interface Root {
id: number;
name: string;
active: boolean;
tags: string[];
specs: Specs;
reviews: Review[];
discontinued: null;
}🔒 Type inference runs entirely in your browser.
</>Use this tool programmaticallycurl · JavaScript · MCP
Same tool, callable from any HTTP client or from Claude (via MCP). Anonymous: 100 req/day per IP. Sign up for 1,000 req/day.
curl
curl https://api.b-e-a-d.com/tools/json-to-ts/run \
-H "Content-Type: application/json" \
-d '{
"input": "your input here",
"rootName": "Root",
"useType": false,
"readonly": false
}'JavaScript (fetch)
const res = await fetch("https://api.b-e-a-d.com/tools/json-to-ts/run", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"input": "your input here",
"rootName": "Root",
"useType": false,
"readonly": false
}),
});
const data = await res.json();
console.log(data.result);MCP (Claude Desktop / Claude Code)
# In Claude Desktop / Claude Code, add to your MCP config:
{
"mcpServers": {
"bead": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.b-e-a-d.com"]
}
}
}
# Then ask Claude to call:
mcp__bead__bead_json_to_tsFull reference: developer docs · OpenAPI spec
How inference works
- Objects become named interfaces, lifted out and named after the field they came from (so a
userfield yields aUserinterface). - Arrays of objects are merged into a single shape — fields missing from any element become optional.
- Arrays of mixed primitives become a union (
(string | number)[]). - Empty arrays become
unknown[];nullvalues widen the field type with| null.
Always sanity-check the output for very dynamic JSON — a single sample can't reveal every possibility.
You might also like
- JSON Schema → TypeScriptEmit TypeScript types from a JSON Schema — enum/oneOf/allOf/$ref/definitions all handled.
- CSV ↔ JSON ConverterConvert CSV to JSON or JSON to CSV with quoted fields and configurable delimiters.
- JSON → Struct / ClassGenerate typed declarations from JSON in TypeScript, Python @dataclass, PHP class, Ruby Struct, Go struct, Rust serde, and Java POJO.
- JSON Sample → Zod SchemaGenerate a z.object({...}) schema with inferred TypeScript type from any JSON sample. Detects UUID/email/URL/date formats.