Paste a JSON sample and get TypeScript interfaces, a Zod schema, Python dataclasses or Go structs.
Saved you some time? ☕ Buy me a coffee
Writing types by hand for a large API response is slow and easy to get wrong. This converter reads a JSON sample, works out the type of every field and prints definitions you can paste into your project. Nested objects become their own named types, and arrays of objects are merged into a single shape.
Paste a JSON object or array into the left box, choose an output language and, if you like, change the root type name. The result updates as you type. Use the Copy button to take the code with you, or press Load sample to see how nested data is handled.
A field that is missing from some objects in an array is marked optional. A field that holds different kinds of values becomes a union in TypeScript, Zod and Python, and any in Go. A null value is kept as nullable. Whole numbers become integers where the language distinguishes them, and any decimal in the same field switches it to a floating point type.
For example, an orders array where only one order has a coupon produces a coupon field that is optional. An empty array has no element type to learn from, so it is typed as unknown. The more representative your sample is, the better the result.
TypeScript interfaces describe data at compile time only. Choose Zod when you also need to validate responses at runtime, for example JSON returned by a language model or a third-party API. The Python option creates standard dataclasses, which describe structure but do not convert nested dictionaries for you. The Go option adds json struct tags so the standard library can decode directly into the types.
No. The conversion runs entirely in your browser.
Yes. The elements are merged into one item type and the root becomes an array of that type.
The sample only contained null or an empty array for it. Add a sample value, or edit the generated type.
No. JSON has no date type, so dates stay as strings.