JSON to TypeScript Converter
Generate TypeScript interfaces, type aliases or Zod schemas from JSON — every array item is read, so optional fields and mixed types come out right.
Runs in your browser. Nothing you add is uploaded.
What the JSON to TypeScript Converter does
Writing TypeScript types by hand for an API response is slow and easy to get wrong, especially when objects are nested and arrays hold items that differ. Paste a sample of the JSON and this tool generates matching interfaces, type aliases or Zod schemas. Unlike tools that look only at the first item of an array, it reads every item: keys that some items lack become optional, fields that hold different kinds of value become unions, and null becomes | null. Objects with the same shape share one type, different shapes get distinct names, and awkward keys such as user-name are quoted correctly. The conversion runs in your browser, so internal API payloads never leave your machine.
How to generate TypeScript types from JSON
- Paste a JSON object or array — ideally a real response, with several items in each array if they differ.
- Set the name of the top-level type, for example UserResponse.
- Choose interfaces, type aliases or a Zod schema, and switch on readonly or all-optional fields if your code style needs them.
- Review the output: nested objects become separately named types, and optional fields are marked with ?.
- Copy the code or download it as a .ts file and drop it into your project.
The JSON to TypeScript Converter runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Typing a third-party API
When a service publishes JSON examples but no TypeScript types, generating them from a real response gives you autocompletion and compile-time checks in minutes, instead of discovering a misspelt field name in production.
Starting a type from a config file
Settings files and fixtures grow over time. Generating a type from the current file documents its shape and makes the compiler warn you when code reads a key that no longer exists.
Reviewing an unfamiliar payload
The generated types are also a compact outline of the data. Reading ten lines of interfaces is quicker than scrolling through five hundred lines of nested JSON.
Good to know
- Types are inferred from the sample you paste. A field that happens to be null or missing in the sample cannot be typed correctly, so use a response with every field filled in.
- Numbers that are sometimes sent as strings ("25") will be typed as string. Fix the type or the API, not both.
- Treat the output as a first draft: add union types for known string values, such as status: "active" | "cancelled", by hand.
- For data you do not control, validate it at runtime as well; TypeScript types disappear when the code is compiled and cannot stop a malformed response.
Frequently asked questions
Does this tool handle nested arrays and objects?
Should I use interface or type?
How are arrays of objects handled?
Is my JSON uploaded anywhere?
Related tools
Regex Builder
Build a regular expression from blocks, with live matches.
SQL Formatter
Format, beautify, and minify SQL queries for Postgres, MySQL, and SQLite.
JSON to YAML Converter
Convert bidirectional JSON to YAML and YAML to JSON with presets.
Chmod Permissions Calculator
Interactive 3x3 Linux permissions matrix, octal sync, and command generator.