All guides

How to convert JSON to TypeScript interfaces

Paste a JSON object or array and generate TypeScript interfaces in your browser.

Why generate types from JSON?

API responses rarely ship with types. Inferring interfaces from a real payload is faster than writing them by hand and helps catch typos in nested fields.

Steps

1) Open JSON → TypeScript at /tools/json-to-typescript. 2) Paste a representative JSON object or array in the left pane. 3) Copy the generated TypeScript from the right pane — it updates as you type. A root array produces an item interface plus `export type Root = RootItem[]`. Nested objects become their own interfaces; keys that appear on only some items are optional.

Worked example

[{"id":1,"name":"Ada"},{"id":2}] makes name optional on the item type because the second object omitted it. Numbers, booleans, and nulls map to TypeScript primitives; nested objects get their own interface names. This is inference from one sample, not a JSON Schema compiler. Invalid JSON is rejected. Fake JSON can give you a sample payload first.

Privacy

Payloads stay in the browser. Related: /tools/json-formatter, /tools/json-validator, /tools/fake-json. Do not paste live PII on a shared machine.

Common mistakes

Inferring types from one happy-path payload will miss optional fields and union types your API actually returns. A null in the sample may become a too-narrow type. This is not JSON Schema and not zod. Root arrays get an item interface plus RootItem[]. Invalid JSON is rejected before codegen. Format first on JSON Formatter if you cannot see the shape. Close the tab on live customer dumps.