JSON to TypeScript converter
To convert JSON to TypeScript, paste sample data below: the tool generates interfaces or types with nested objects, arrays and optional fields – or a JSON Schema. Your data stays in the browser.
Source: TypeScript Handbook – Object Types (interfaces, optional properties, readonly). Updated: .
How it is calculated
Converting JSON to TypeScript means deriving the matching types from sample data. {"id": 1, "name": "Anna"} becomes an interface with id: number and name: string. The tool reads your JSON in your browser, merges objects of the same kind and writes the types as source code – with no upload.
How it works
- Paste JSON into the field, for example an API response.
- Choose the output: interfaces, types (type) or JSON Schema. Set names, export, readonly and indentation as you like.
- Copy the result and paste it into your project.
How the types are built
- Numbers, text, booleans: number, string, boolean (integer or number in the schema).
- Arrays: all elements are merged. Mixed elements become unions such as (string | number)[]; an empty array becomes unknown[].
- Objects: fields that are not in all objects get a question mark (optional). Objects with the same shape share one type.
- Names: nested objects are named after their key in PascalCase, in the singular for arrays (orders → Order). Keys such as
"e-mail"are put in quotes.
Limits
The result is a draft: check it against the documentation of the interface, because sample data does not show every possible case.
- Sample data only – value ranges, enumerations and date formats cannot be derived from it (date texts stay string).
- Up to 500,000 characters and 200 levels of depth; JSON numbers do not distinguish int from float, and the schema uses integer only when all sample values are whole numbers.
Privacy
The JSON never leaves your browser. Next steps: format JSON, CSV to JSON or YAML to JSON.
Frequently asked questions
How do I convert JSON to TypeScript?
Paste the JSON and choose “TypeScript interfaces”: the tool generates interfaces with all fields, nested types and arrays. Copy it into your project.
Interface or type – which is better?
Both describe the same shape. Interfaces can be extended and often give better error messages; type is more flexible with unions. The tool generates either on request.
How does the tool detect optional fields?
A field that is missing in one object but present in another gets a question mark. Several objects in an array are merged for this.
Can I also generate a JSON Schema?
Yes, choose “JSON Schema (2020-12)”. The schema contains types, nested properties and the list of required fields.
Is my JSON uploaded?
No. The types are created entirely in your browser.
Sources and legal basis
- TypeScript Handbook – Object Types (interfaces, optional properties, readonly)
- JSON Schema – Draft 2020-12
- IETF – RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format
As of: · Editorial policy
Related tools
- JSON formatter, validator and minifierValidate JSON against RFC 8259 with the exact line, column and a plain-English explanation. Beautify or minify, sort keys, copy. Runs locally in your browser.
- JSON-LD GeneratorJSON-LD generator for Schema.org: fill in an article, FAQ, product, local business or organization and copy ready-to-use code with a built-in error check.
- YAML to JSON converter (and JSON to YAML)YAML to JSON converter and JSON to YAML following YAML 1.2: lists, anchors, text blocks, comments. Errors show the line number. Runs in your browser, no upload.
- CSV to JSON converter (and JSON to CSV)Convert CSV to JSON or JSON to CSV online: delimiter auto-detected, numbers and booleans typed, quoted fields handled. Runs in your browser, nothing uploaded.
- XML formatterXML formatter: beautify, minify and validate with line and column of the error, tree view, XPath query and XML to JSON. In your browser, no upload.
- Regex TesterTest JavaScript regular expressions live: matches highlighted, capture groups in a table, every part of the pattern explained. Free, nothing uploaded.
- What is my IP address?What is my IP? See your public IPv4 or IPv6 address at once, plus approximate location, internet provider and browser details. Free, never stored.
- CSV to SQL converterConvert CSV to SQL: generate CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. Types detected, in your browser, no upload.
- IBAN CheckerValidate any IBAN: mod-97 check digits, length and structure for 89 countries, plus bank and BIC for German IBANs. Runs in your browser – nothing is sent.