Don's Tools · Developers · JSON to TypeScript, Pydantic & Zod

JSON to TypeScript, Pydantic & Zod

Paste a JSON sample and get TypeScript interfaces, Pydantic models or Zod schemas, with nesting, arrays and optional fields handled, all in your browser.

JSON to Types turns a JSON sample into typed models in your browser. Paste an object or an array of objects and instantly generate TypeScript interfaces, Python Pydantic models or Zod schemas, switching between them with the tabs. Nested objects become their own named types, array items are merged so fields missing from some entries are marked optional, and null values become nullable. It is handy for typing API responses and validating structured LLM outputs, and nothing you paste is uploaded.

Files are processed in your browser and never uploaded.

How to use JSON to TypeScript, Pydantic & Zod

  1. Add your text

    Type or paste your text into the input box. Everything is handled by your own browser, so nothing is sent to a server.

  2. Set the options

    Choose Root type name. The options are visible from the start, not hidden until you paste something.

  3. Run it and keep a copy

    Press TypeScript to produce the result. Copy puts the result on your clipboard.

What this tool does

TypeScript, Pydantic and Zod from one sample

One JSON sample gives you TypeScript interfaces, Pydantic models or Zod schemas, and the tabs switch between them without re-pasting.

Nested objects become their own named types

A nested object becomes its own named type rather than an inline blob, so the result is readable and reusable.

Merges array items and marks optional fields

Array items are merged so the type covers every element, and a field missing from some of them is marked optional.

Detects nullable values

A field that is null in the sample is typed as nullable rather than being guessed at or dropped.

Runs in your browser, nothing uploaded

The sample is parsed in your browser, which matters when the easiest sample to hand is a real API response.

Frequently asked questions

Is my JSON uploaded anywhere?

No. The JSON is parsed and the types are generated entirely in your browser. Nothing you paste is sent anywhere or stored.

What can it generate?

TypeScript interfaces, Python Pydantic models and Zod schemas, from a single JSON sample. Switch between them with the tabs and copy the result.

How does it handle nested objects and arrays?

Nested objects become their own named types, and arrays use the element type. If an array holds several objects, their fields are merged and any field missing from some of them is marked optional.

Why is a field marked optional or nullable?

A field is optional when it appears in only some objects of an array, and nullable when a value was null. This keeps the generated types honest about what your data actually contains.

Is this useful for structured LLM outputs?

Yes. Paste an example of the JSON you expect a model to return and you instantly get a Pydantic model or Zod schema to validate it against, or a TypeScript interface for your code.

Last updated: