JSON to TypeScript
Turn JSON into named TypeScript interfaces with nested types and array element typing.
How to use it
- Paste your JSON into the left panel — a sample payload loads on start.
- Set the root interface name; nested interfaces are named from their key paths.
- Toggle optional fields to mark keys that are missing in some sibling objects with
?. - The output updates as you type; click Copy to take the interfaces into your project.
- Name collisions get numeric suffixes, and non-identifier keys are emitted as
['quoted-key'].
Common use cases
- API clients — generate request and response types from a real payload instead of writing them by hand.
- Config files — type your JSON settings file so edits are checked at compile time.
- Test fixtures — describe fixture shapes once and reuse them across test files.
- Learning type shapes — see how nested arrays of objects decompose into named interfaces.
Why it stays private
Parsing and code generation are local string operations; your JSON is never uploaded. Safe for internal payloads, tokens-free but unreleased API shapes, and customer data samples.
FAQ
Q: How are arrays of objects handled?
A: All object elements are merged into one interface covering their key union; the array itself is typed as that interface name followed by []. Non-object elements contribute a union member when they differ.
Q: What happens to null values?
A: null becomes the null type and joins any union, so a field that is string in one place and null in another comes out as string | null.
Q: Are identical nested shapes deduplicated? A: Not structurally — deduplication is by generated name only. Two objects with the same keys but different names produce two interfaces; merge them manually if you want a single shared type.
Your data stays on this device
JSON to TypeScript runs 100% locally. Everything you paste or drop is processed by your own browser and never transmitted. Nothing is stored on our servers — close the tab and it is gone.
Nothing you type is sent to a server, logged, or used for analytics. The page works even with your network disconnected after first load.