About the JSON to TypeScript / Zod / Go
Writing types for an API response by hand is slow and easy to get wrong. Paste a sample response and get clean TypeScript, Zod or Go types you can drop into a project.
When you call an API from TypeScript, you need types that describe the response, otherwise the compiler cannot help you catch mistakes. Writing those types by hand for a large, nested response is tedious and error-prone. This tool reads a sample of real JSON and generates matching TypeScript definitions, so you start from accurate types and only refine them.
Nested objects become their own named interfaces, arrays are typed from their contents, keys missing from some items in an array are marked optional, and null values become union types. You can choose interface or type syntax, set the root name, mark every property readonly, and decide where null appears in unions. It is useful for front-end developers, Node.js developers and anyone documenting an API.
How to use the JSON to TypeScript / Zod / Go
- 1Paste a JSON sample.
- 2Choose interface or type, and the root name.
- 3Copy the TypeScript.
Key features
- Separate named interfaces for nested objects.
- Optional keys inferred from arrays of objects.
- Null values turned into union types.
- interface or type output, with a custom root name.
- Readonly option for immutable data.
Practical uses
- Typing a REST API response in a React or Angular app.
- Creating types for a JSON configuration file.
- Documenting webhook payloads for a team.
- Speeding up migration of a JavaScript project to TypeScript.
Example
A sample like {"id":1,"name":"Ali","tags":["a"],"address":{"city":"Lahore"}} with the root name User produces an interface User with id: number, name: string, tags: string[] and address: Address, plus a separate Address interface with city: string.
Tips and common mistakes
- Paste a sample that contains every field, including rare ones, or they will be missing from the types.
- Use an array of several records so optional keys can be detected.
- Review generated names and rename them to match your domain language.
Limitations
- Types are inferred from one sample, so string values that are really enums or dates are typed as string.
- Empty arrays become unknown[] because there is nothing to infer from.
Privacy
The JSON is converted in your browser and never uploaded, so internal API responses stay private.
Frequently asked questions
How are optional keys found?
If an array contains objects where a key is missing in some items, that key is marked optional (?).
What about null values?
They become null in a union type, for example string | null, when other items have a value.
Is my JSON sent anywhere?
No. It is converted in your browser.
Can it generate Zod or JSON Schema?
No. It produces TypeScript interfaces and types only.
Can I paste a JSON array?
Yes. Objects inside the array are combined into one item type, and keys missing from some items are marked optional. The root name is then used for an array type.