←
Developer

JSON to TypeScript

Loading the tool…

Ready when you are.Runs in this browser · nothing is uploaded

TypeScript types from JSON

  • Free
  • No sign-up
  • No upload
  • Works offline

Tool facts

Opens
JSON
Saves as
TS
Price
Free, no sign-up, no watermark
Are files uploaded?
No. Everything is processed in this browser, on your device.
Batch processing
One file at a time
Offline use
Works without a connection once this page has loaded
Browser
A recent Chrome, Edge, Firefox or Safari, on computer or phone.

Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.

About JSON to TypeScript

JSON to TypeScript reads a JSON sample, such as an API response or a config file, and writes matching TypeScript declarations as you type. Every nested object gets its own interface named after its key, arrays of objects get a singular item name (users becomes User), and objects with exactly the same shape share one type instead of being repeated.

When an array holds objects with different keys, the objects are merged and keys that are missing in some items are marked optional with ?. Arrays that mix types become unions such as (number | string)[], null values add | null, and an empty array becomes unknown[] because there is nothing to infer from. Keys that are not valid identifiers are quoted. You can output interfaces, type aliases or a Zod schema with inferred types, and the JSON never leaves your browser.

JSON to TypeScript runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.

How to use JSON to TypeScript

  1. Paste JSON into the JSON input box, or open or drop a .json file. A sample is loaded so you can see the result first.
  2. Pick Interfaces, Type aliases or Zod under Output style and set the Root type name.
  3. Turn on All properties optional, Readonly properties or the export keyword as needed.
  4. Copy the generated code or download it as a .ts file.

Frequently asked questions

How are optional properties detected?

Only from arrays of objects. When some items of an array have a key and others do not, that key gets a question mark. A single object has no way to show which keys are optional, so all of its keys are required unless you turn on All properties optional.

Why is a field typed as string and not Date?

JSON has no date type; dates arrive as strings and JSON.parse keeps them as strings. The generated type describes what your code actually receives, so ISO dates stay string.

How are type names chosen?

Names come from the property key in PascalCase, so billing_address becomes BillingAddress. Array items use the singular form when the key is a simple plural (categories becomes Category), otherwise Item is appended. If two different shapes would get the same name, a number is added, and names of built-in types such as Date or Location get a Type suffix.

What does the Zod output need?

It imports z from the zod package and declares one schema per object type, children first, plus a z.infer type for each. Optional keys use .optional() and null values use .nullable(). Install zod in your project to use it.

Is my JSON sent anywhere?

No. Parsing and type inference run in JavaScript in your browser tab, so API responses with tokens or customer data stay on your device.

· Free · Runs in this browser · nothing is uploaded

Drop any file here
Drop it to see which tools can open it