Dev · Free tool

JSON to TypeScript Converter

Paste a JSON object or array, get a typed TypeScript interface back — instantly, in your browser.

Convert JSON to a TypeScript interface

Paste any JSON object or array. The interface regenerates as you type.

TypeScript output

types.ts
interface Author {
	name: string;
	id: number;
}

interface Root {
	id: string;
	title: string;
	published: boolean;
	views: number;
	tags: string[];
	author: Author;
}

How it works

Conversion runs entirely client-side: your JSON is parsed and walked in the browser to infer field types, with nested objects promoted to their own named interface. Nothing is uploaded or logged — this is the same structural-typing approach a schema-driven content API uses to generate a full client, just run on a single sample instead of a declared schema.

Interface vs. type: which one is this?

This tool emits interface declarations, not type aliases — for a plain object shape they behave the same way in TypeScript, but an interface can be reopened and extended, which matches how a JSON shape usually needs edits later. Swapping the generated interface Foo { for type Foo = { works with no other changes if your codebase standardizes on type.

Converting a JS object, not raw JSON

Already have a JavaScript object instead of a JSON string — from an API response you logged, or a fixture in a test file? Run it through JSON.stringify(value) first, or just rewrite single quotes to double quotes and quote the keys — valid JSON is all this tool needs, it doesn’t care where the value came from.

Nested objects, arrays, and optional fields

Every nested object gets promoted to its own named interface rather than inlined, so a deeply nested payload produces several small, readable interfaces instead of one wall of braces. What the tool can’t infer from a single sample: fields that are sometimes missing (mark those field?: type by hand) and fields that hold more than one shape across different responses (a union type, which needs a second sample to spot). A JSON-RPC response from an MCP server is exactly this kind of payload — paste one through this tool after inspecting it with the MCP Inspector.

Get types generated from a real schema, not a sample

Draftbase generates a full typed client from your actual content schema via draftbase types — run in CI, so types never drift from what the API returns.

Hobby is free, no card. Startup is $49/mo when you outgrow it. The price is on the pricing page, where prices go.

No migration quarter, no kickoff workshop. Define a template and ship something today.

Frequently asked questions

How does JSON get converted to TypeScript?

The tool walks the parsed JSON value by value: primitives map to string, number, or boolean; arrays infer their element type from the first item; nested objects become their own named interface. It’s a structural inference from one sample, not a schema — fields that are sometimes absent or sometimes a different type won’t be caught.

Why does an empty array produce unknown[]?

An empty array carries no element to infer a type from, so unknown[] is the honest answer rather than a guess. Add a sample item to the array to get a real element type.

Is this safe for production types?

Treat the output as a starting point. It’s inferred from one JSON sample, so optional fields, unions, and enums won’t be detected — review and adjust before committing generated types.

More free tools on the tools page, or read the content modeling guide on /content-modeling.