JSON to TypeScript
About this tool
Matching frontend types to a live response is faster than copying from DevTools. Choose interface or type, and mark every field optional when the contract is still moving. This is one snapshot, not a spec—enums and comments you still add.
Features
- Emits interface or type aliases
- Splits nested objects into named types
- Optional-all-fields switch for early drafts
How to use
- Paste a real response, including empty and missing keys if you can.
- Pick interface or type and name the root.
- Enable optional fields while the API still omits keys.
- Copy, then narrow any, wide numbers, and unions.
When to use it
- Frontend needs types for a payload you just captured
- No OpenAPI yet, so a sample has to stand in
- Keys are often absent; mark them optional first
Examples
- {"id":1,"name":"Ada"} becomes id: number and name: string.
- With optional on, fields are id?: number so missing keys type-check.
FAQ
Does it emit union types?
It follows the sample. If a field is sometimes an object and sometimes null, tighten the union yourself.
How is this different from OpenAPI codegen?
One JSON snapshot, no enums or required flags from a spec. Prefer OpenAPI when you have one.
Interface or type?
Interfaces fit object shapes. Use type aliases for unions. Generate first, then match your repo style.
When should every field be optional?
While the API still drops keys. Tighten required fields once the contract is stable.
Is the JSON uploaded?
No. Generation runs locally.
JSON to Go instead?
Use JSON to Go for server structs. Pretty-print the same sample first if the tree is hard to read.
Back to JSON Tools Hub
Guides