Tools · TypeScript

JSON to TypeScript

The same data, written as the types a client would want — one interface per object, nested, from the response you already have.

JSON, YAML, XML, CSV, a log file, or something broken. It stays in this tab.
try
no signup · runs entirely in your browser · ⌘V works anywhere on this page

What it does

  • Writes the API-response sample as 7 interfaces in 54 lines
  • Gives each nested object its own interface, named from its key
  • Types an array from every element, not the first: the paginated list's 3 interfaces mark failure_message optional, because two of three charges lack it
  • Keeps null as null; a field that is sometimes null is a union — failure_code: string | null
  • Names the root after the file: clean-order-example.json → CleanOrderExample

What it will not do

  • Write Zod, JSON Schema or io-ts. Interfaces only.
  • Infer formats. A date string is a string, an id is a string — it types what is there.
  • Send your text anywhere. The page is static and the engine runs in this tab — open the network panel and watch it stay empty.

The sample

The text below is what the first chip opens — a real document the engine reads, not an illustration written for this page.

clean-order-example.json → TypeScript, as Convert writes it
export interface CleanOrderExample {
  order_id: string;
  created_at: string;
  status: string;
  customer: Customer;
  items: Item[];
  shipping: Shipping;
  totals: Totals;
  metadata: Metadata;
}

export interface Customer {
…

How

  1. Paste the response.
  2. Open the tree, press Convert, then TypeScript. Focus a branch first to type only that branch.
  3. Copy — the Foot says how many bytes — or download the .ts.

Questions

Does it handle nested objects and arrays of objects?

Yes: each nested object becomes its own interface, and an array of objects is typed from all of its elements.

What happens when a field is null?

It is typed null. When another element has a value there, the field is a union of the two.

Can I type just one branch?

Yes — focus it in the tree (f), and Convert acts on that branch instead of the file.

Is the output deterministic?

Yes. The same JSON gives the same interfaces every time; there is no model involved.

Try it on the file that broke your afternoon.

free while in alpha · no signup