Skip to content

← All tools

JSON to TypeScript / Zod / Pydantic Converter

Paste a JSON payload and get clean, ready-to-use types: TypeScript interfaces, Zod schemas, Pydantic models or Go structs. Nested objects become named types, and fields missing from some array elements are detected as optional — all inferred locally in your browser.

New to this? Read the JSON-to-types guide →

Generated types

        

Everything runs locally in your browser — your JSON is never uploaded, so it's safe to paste real API responses. Validation errors in the input? Run it through the JSON validator first.

How to generate types from JSON

  1. Paste any JSON — an API response, a config file, a database row. Types generate as you type.
  2. Pick the output: TypeScript interfaces, a Zod schema (with inferred TS types), Pydantic models, or Go structs with JSON tags.
  3. Name the root type, copy, and paste into your codebase.

What the inference understands

Nested objects become named types (an orders array yields an Order type). Array elements are merged, so a key present in only some elements comes out optionaldiscount?: number, .optional(), | None = None, or ,omitempty depending on the target. Nulls become nullable types, mixed arrays become unions, and integer-only samples produce z.number().int(), Pydantic int and Go int64. Details and caveats are in the guide.

Frequently asked questions

How do I convert JSON to TypeScript types?

Paste the JSON and the TypeScript interfaces generate immediately — nested objects become named interfaces (orders becomes Order), and you can switch the same inference to Zod, Pydantic or Go output with one click.

How does it know a field is optional?

By merging array elements: a key present in every element is required, a key present in only some becomes optional — emitted as ?: in TypeScript, .optional() in Zod, | None = None in Pydantic and ,omitempty in Go. More sample elements produce better types.

Is my JSON uploaded?

No. Parsing, inference and code generation all run in your browser, so pasting a real production API response is safe. It works offline once the page has loaded.

Should I use TypeScript interfaces or a Zod schema?

Interfaces if you only need compile-time checking. Use Zod when the data crosses a trust boundary (API responses, user input) — a Zod schema validates at runtime and gives you the static type for free via z.infer.

Can I trust the generated types completely?

They describe the sample you pasted, not the API’s full contract: fields your sample never showed won’t appear, and strings that are really dates or enums stay plain strings. Generate first, then spend two minutes tightening.

Related reading

Related tools