JSON to TypeScript
Paste JSON and get TypeScript types in this tab. Objects become named interfaces, mixed arrays become unions, and a field missing from some items is marked optional. ISO date strings stay string. Nothing is uploaded.
Input
Result
How to use JSON to TypeScript
- Paste or open JSONType, paste, or open a .json file. The limit is 1 MB. Comments and trailing commas are not accepted — only standard JSON.
- Name the root typeSet a TypeScript type name for the root, such as Root, and choose whether each type is exported. Then convert the JSON.
- Copy or downloadCopy the types or download types.ts. If the JSON is invalid, an error is shown instead of a type file.
Limits and how it works
- The input is limited to 1 MB of UTF-8 text, including files you open, a maximum depth of 64, and a cap on how many values can be walked.
- Only standard JSON is accepted. Comments, trailing commas, and JSON5 or JSONC syntax are rejected.
- ISO date strings, UUIDs, and similar formats stay string. They are not turned into Date or branded types.
- A syntax error is reported without repeating the input. The file is not repaired automatically.
How types are inferred
This page walks the parsed JSON and writes TypeScript. Object values become interfaces. Arrays of objects merge their fields: a key present in every item is required, and a key missing from some items is optional. Mixed item types become a union such as string | number. Empty arrays are unknown[]. Null stays null, so a field that is sometimes a string and sometimes null is string | null.
The inferencer is written for this page. It does not use quicktype-core. That library is Apache-2.0, which is allowed, but the published package is about 4.2 MB unpacked — too large to ship here. This built-in typist does not infer Date from ISO-8601 strings; those values stay string. It does not read JSONC or JSON5.
JSON numbers follow JavaScript’s IEEE-754 precision. Integers larger than 2^53−1 may already be rounded by JSON.parse before types are written. Property names that are not valid identifiers, or reserved words such as class, are quoted. This is a typist, not a runtime validator.
Frequently asked questions
Is my JSON uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste, or open is sent to a server, logged, or stored by ALink Tools.
Is this the Schema Generator?
No. Schema Generator writes Schema.org JSON-LD markup for pages. This tool infers TypeScript interfaces from a JSON value.
Why don’t you use quicktype?
quicktype-core is Apache-2.0, but the published package is about 4.2 MB unpacked. This page uses a smaller built-in inferencer instead.
Will an ISO date become Date?
No. Strings stay string, including ISO-8601 timestamps. You can change a field to Date by hand if your code parses it.
Related tools
All toolsJSON Formatter & Validator
Format, minify, sort keys, and catch syntax errors cleanly.
JSON to YAML
Convert JSON to YAML in your browser with js-yaml. Set the indentation and sort keys if you need a consistent output.
JSON to CSV
Turn a JSON array of objects into a CSV table, with optional flattening of nested keys.
TOML to JSON
Convert TOML to JSON in your browser with smol-toml, or JSON back to TOML.