JSON to TypeScript Interface

Paste JSON and TypeScript interfaces are generated live. Nested objects split into their own interfaces; arrays, nulls, and mixed types are inferred precisely.

JSON input
TypeScript output
 

How to Use

1
Paste JSON

Paste JSON on the left — single object, array, or nested structure. Parse errors show the offending position.

2
Tweak options

Set the root interface name, force all fields optional, sort keys, and more.

3
Copy the output

TypeScript interfaces appear live on the right. One click copies them, ready to paste into a .ts file.

FAQ

How are nested objects handled?

Each nested object becomes its own interface. The name comes from the parent key, PascalCased. e.g., `user.address` → an `Address` interface.

How are array types inferred?

Items are scanned: a single type yields `T[]`, mixed yields `(A | B)[]`. Object arrays use the first item as the schema, and missing keys across items become optional (`?`).

What about null fields?

Fields seen only as `null` get the `null` type. Mixed values produce unions like `string | null`. Toggling "All fields optional" also adds `?` markers.

When keys aren't valid identifiers?

Keys with hyphens or special characters are auto-quoted. e.g., `"my-key": string`.

Is anything sent to a server?

No. All conversion runs in your browser; nothing leaves the page.