JSON to TypeScript
Runs on your device — nothing you enter is uploaded
Paste JSON and the interfaces appear as you type.
Paste a JSON object or an API response and this tool writes the matching TypeScript interfaces as you type. Nested objects get their own named interfaces, arrays of objects are merged so keys that only some items have become optional, and values that are sometimes null are typed as a union such as string | null. Rename the root interface, switch between interface and type, then copy the result into your code. The conversion runs entirely in your browser, so private API payloads are never uploaded.
Suggest an improvement to this tool
Frequently asked questions
How are arrays of objects typed?
All items are merged into one interface. A key that is missing from some items becomes optional (key?: type), and a key whose value is sometimes null becomes a union with null.
What happens with null or empty arrays?
A value that is always null is typed as null, and an empty array is typed as unknown[] because there is nothing to infer from. Replace those with the real types once you know them.
Is my JSON sent to a server?
No. The conversion is plain JavaScript running in this page. Nothing you paste is uploaded or stored; only your root name and option choices are remembered on this device.
Can I convert a JSON array at the top level?
Yes. A top-level array becomes a type alias such as type Root = RootItem[], with an interface for the items.