Skip to content
Json Works

Runs in your browser · nothing is uploaded

JSON to TypeScript Converter

Generate TypeScript interfaces, JSON Schema or Zod from a JSON sample. Optional and nullable fields are detected across array items. Runs in your browser.

JSON sample

Empty

Output

—

Types from real data, not guesses

Hand-writing types for a 40-field API response is tedious and error-prone. Paste the response and get accurate, merged types — including the optional fields you would have missed — ready to drop into your codebase.

Interfaces, types and JSON Schema

TypeScript describes the shape of data with interface or type declarations. JSON Schema is a language-neutral way to describe the same shape, used for validation in many frameworks and API tools. This tool can output any of the three from the same sample, so you can pick whichever your project uses.

Example

A response like {"id": 7, "email": "ada@example.com", "tags": ["admin"]} becomes an interface with id: number, email: string and tags: string[]. When you paste an array of objects, keys that are missing from some items are marked optional, and values that vary between items become union types.

Getting accurate types

  • Paste a sample that represents the real range of data, not just the first record. A field that is sometimes null should appear as null at least once.
  • Review the names the tool chooses for nested objects and rename them to match your domain.
  • Generated types describe a sample, not a contract. For data you do not control, validate at runtime as well.
  • Dates arrive in JSON as strings; convert them yourself after parsing.

The JSON to TypeScript interfaces guide covers optional fields, unions and nested structures in depth. To confirm your sample is valid first, run it through the JSON Formatter.

How to use JSON to TypeScript

  1. Paste a JSON sample — a real API response gives the best types.
  2. Pick the output: interfaces, types, JSON Schema or Zod, and set the root name.
  3. Copy the result into your project or download it as a .ts / .json file.

Private by design

JSON to TypeScript runs entirely in your browser. Your data is parsed and converted on your device with JavaScript — it is never sent to a server, logged or used for analytics. Recent inputs are kept in your browser’s own storage so you can come back to them, and they disappear when you clear cookies and site data (or press Clear history). You can verify this in your browser’s network tab.

Frequently asked questions

How does it know which fields are optional?

When your JSON has an array of objects, all items are merged. A field missing from some items becomes optional (?), and a field that is sometimes null becomes T | null. Fields with different types across items become a union.

Can I get a JSON Schema or Zod schema instead?

Yes. Switch the output between TypeScript interfaces, type aliases, JSON Schema (draft-07) and a Zod schema with inferred type.

How are nested objects named?

Each nested object becomes its own named type from its property name — customer becomes Customer, and items[] becomes Item. Name clashes get a numeric suffix.

Is my JSON sent anywhere?

No. Types are generated entirely in your browser.

Found a bug or have an idea for this tool? Send feedback.

Guides for JSON to TypeScript

More JSON tools

History

Saved only in this browser (IndexedDB). It never leaves your device and disappears when you clear cookies and site data.