How to turn JSON into TypeScript
- Paste JSON, such as an API response, or open a .json file.
- Choose interface or type, a root name, and whether to add readonly and export.
- Copy the generated TypeScript, Zod schema, or JSON Schema, or download it.
Nested objects become their own named interfaces, named after their keys (a key called "orders" gives an Order type for its items). The more varied examples you include in an array, the more accurate the optional fields and unions are.
Questions
Is my JSON uploaded?
No. The types are worked out in your browser, so API responses and config files stay on your device.
How are arrays with different objects handled?
The objects are merged into one type. A key that is missing from some of them becomes optional (key?: ...), and a key whose values differ gets a union such as string | number.
How are null values and empty arrays typed?
A null value becomes null, or a union such as string | null when other items have a value. An empty array has nothing to learn from, so it becomes unknown[].
Can I get a Zod schema or JSON Schema instead?
Yes. Switch the output to Zod to get a z.object(...) schema plus its inferred type, or to JSON Schema (draft 2020-12) for validators and OpenAPI-style tooling.
Are the types guaranteed to match every response?
They match the sample you pasted. A single example cannot show every variation, so paste a few responses in an array, or review optional fields and unions by hand.
Credits
Built by OneTooling using standard browser features. No third-party code runs on your data.