From an API response to code you can paste. No sign-up and no upload.
Paste a real JSON response, or drop or upload a .json file.
Comments allowedinterface, type alias or Zod schema, with your own root type name.
Updates as you typeCopy the code, or save it as a .ts file named after the root type.
Ready to pasteInput is read with JSON5, so comments, trailing commas, single quotes and unquoted keys are all fine.
Paste an actual response, not a hand-written one. The more items an array has, the better the merge.
Set the root type name, such as User or OrderResponse. Nested types are named after their keys.
interface for plain object shapes, type for aliases, or Zod to check data at runtime too.
Check optional fields and unions against the API docs, then copy or download the file.
A generator only sees your sample. These habits make the sample tell the truth.
Put several items in each array. Keys missing from some items become optional.
A string set becomes a union only when a value repeats and there are 2 to 12 of them.
Nested types are named from keys, like Address or RolesItem. Rename them to match your codebase.
Types vanish when TypeScript compiles. Zod checks real data when it arrives.
The rules the generator applies, so you know what to check.
Every object in an array merges into one type with the union of all keys.
Repeated strings with 2 to 12 distinct values become "a" | "b".
A field that is a number in one item and a string in another becomes string | number.
Keys that are not valid identifiers, like first-name, are written in quotes.
Anyone who calls an API from TypeScript writes these types sooner or later.
Fetch calls return untyped JSON. A generated interface turns it into autocomplete and checks.
Third-party webhooks and APIs send JSON you don't control.
App screens read the same API payloads as the web, and need the same types.
Typed fixtures catch a test that drifts from the real response shape.
What the generator writes for each kind of value, and what it cannot know.
How each JSON value is typed.
How nesting turns into named types.
Things a sample doesn't show. Add them by hand.
APIs change. These habits stop your types from drifting.
Save the JSON you generated from next to the types, so the next update starts from the same place.
When the API adds a field, paste a new sample and compare the output with your file.
A Zod schema throws on parse() when real data stops matching, instead of failing quietly later.
If the API ships an OpenAPI spec or an SDK with types, use those. Generated types are the fallback.
Three ways to type an API response. Pick by what the API gives you.
| Feature | This generator | Hand-written | From an OpenAPI spec |
|---|---|---|---|
| Needs | ✓ One JSON sample | Time and the docs | A published spec |
| Speed | ✓ Seconds | ✗ Slow for big payloads | ✓ Seconds, once set up |
| Optional fields | Only if the sample shows them | ✓ From the docs | ✓ From the spec |
| Runtime check | ✓ Zod output | Write it yourself | Extra tooling |
| Stays in sync | ✗ Regenerate by hand | ✗ By hand | ✓ Rerun the build |
| Data leaves your device | ✓ Never | ✓ Never | ✓ Never |
JSON won't parse? Find the error with the JSON formatter first.
Small habits that make the output ready to commit.
Wrap two or three responses in one array to see which fields are really optional.
One "admin" and one "editor" stay string. Add a second "editor" to get a union.
A null value types as null, not key?. Decide which your code should expect.
Turn on All fields optional for PATCH bodies and partial updates.
The Zod output imports from "zod". Install it in your project before you paste.
Paste JSON with comments or trailing commas. JSON5 reads it, and Format cleans it up.
The download is named after the root type, like User.ts or User.schema.ts for Zod.
Responses with tokens or customer data are parsed in this tab and never uploaded.
TypeScript types are removed when your code compiles, so a response that doesn't match still gets through. If the data comes from outside your code, generate a Zod schema and parse it where it arrives.
For plain object shapes they are almost the same. The TypeScript Handbook explains the one real difference.
Can be re-opened: two interfaces with the same name merge. The Handbook suggests using interface until you need a feature of type.
Best for API response shapes
Can't be re-opened once created, but can name unions and other types an interface can't, like string | number.
Best when you will combine types
Six everyday jobs that start with an untyped JSON payload.
Turn the response of a new endpoint into an interface in seconds.
Generate a Zod schema to check webhook bodies before you use them.
Replace any with real types while moving a codebase to TypeScript.
Type test data so tests fail when the real shape changes.
Type a JSON config file so a typo in a key is caught at build time.
See how objects, arrays and unions map to types.
Have CSV instead? Convert it with CSV to JSON first.
Quick answers about inference, Zod and privacy.
Reviews from people who used this tool.
Loading reviews…
Jump to a version of this tool already set up for a specific need.
Free, with no sign-up, just like this one.
Paste a JSON sample and get TypeScript interfaces, type aliases or a Zod schema as you type. Arrays of objects merge into one type, and repeated strings become enums. Nothing is uploaded.
interface · type · Zod schema from any JSON
Comments, trailing commas and single quotes are fine. .
Paste JSON on the left. The types appear here as you type.
Tools that pick up where this one leaves off.