A free JSON to TypeScript converter
Typing an API response by hand is slow and easy to get wrong, especially when it's nested several levels deep. This JSON to TypeScript converter reads your data and writes the types for you: strings, numbers, booleans, arrays and nested objects, with each nested object as its own named interface so the result stays readable.
Names come from the keys. A user key becomes a User interface, and an items array becomes Item[]. Keys that aren't valid identifiers, such as first-name, are quoted automatically, and a JSON file whose root is an array produces a Root type for the array plus a type for its items. It's one of our free developer tools that run in your browser, with no sign-up and no limits.
Convert a JSON response to a TypeScript interface
The most common use is typing what an API sends back. Open your browser's Network tab, copy the response body, paste it here and you have an interface for fetch or axios in seconds. Paste a response that includes a few items rather than one, so the converter can spot which fields are optional.
Many API responses also carry an access token. If you need to see what's inside one, use our JWT decoder to read its claims and check when it expires, also without sending it anywhere.
Generate a Zod schema from JSON
TypeScript types disappear when your code runs, so they can't tell you whether an API actually returned what you expected. A Zod schema can. Switch to the Zod tab and this JSON to Zod converter gives you a schema for every object, plus a matching type created with z.infer, so the types and the runtime check never drift apart.
With format checks on, strings that all look like dates, emails or URLs get .datetime(), .date(), .email() or .url(), and whole numbers get .int(). Turn those options off if your real data is less consistent than your sample. The output works with Zod 3 and Zod 4.
Optional fields, nulls and mixed arrays
One sample is only a guess at the real shape of your data, so the converter looks at every item in an array before deciding. If a key is missing from some items, it's marked optional (name?: string, or .optional() in Zod). A value that's sometimes null becomes string | null, or .nullable() in Zod, and arrays that mix types get a union such as (number | string)[].
JSON to TypeScript type or interface?
For plain object shapes like API responses, the two are almost interchangeable. Interfaces are the common choice in many codebases and can be extended and merged; type aliases are needed for unions and some advanced patterns. Pick whichever your project already uses; the readonly and export options apply to both.
If an AI coding assistant writes much of your code, tell it which style you prefer once, in a rules file, instead of correcting it every time. Our CLAUDE.md generator builds that file for Claude Code, Cursor and Copilot, including rules like “validate API data with Zod”.
Messy JSON is fixed for you
Copied an object from JavaScript code or a config file? Comments, single quotes, unquoted keys and trailing commas are cleaned up automatically, and the tool tells you what it fixed. If the JSON is really broken, you'll see the line and column of the problem instead of a vague error.
Private by design
API responses often contain real names, emails or tokens. This converter is plain code running in your browser, with no server and no AI model, so nothing you paste is uploaded or stored. It even keeps working if you go offline after the page has loaded.