JSON to TypeScript
Paste a JSON value and get TypeScript type declarations for it. Nested objects become their own named types (RootAddress, RootUser), arrays can be merged across every element so missing keys become optional, and null or mixed values turn into unions. Runs entirely on your device.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
From a sample to named type declarations
The tool parses one JSON value and emits TypeScript types for it. Every nested object becomes its own named type, with the name built from the parent name plus the key — an address field under Root becomes RootAddress. Array element objects get an Item suffix, so an array under a users key becomes RootUsersItem[]. The output is a runnable set of interface or type declarations you can paste into a project.
Merging every element of an array
When Merge shape of every array element is on, the tool unions the shapes of all objects in an array rather than trusting only the first one. Keys present in some but not all elements become optional, and the value type is a union of every distinct type seen. Turn it off to sample just the first element and keep the type tighter.
Choices that change the output
Root type name sets the name of the top-level declaration, and defaults to Root. Prefer interface produces interface blocks with semicolon properties; disabling it emits type aliases with equals signs. Mark properties readonly prefixes every field with readonly. Any key that is not a valid identifier is quoted, and a root name starting with a digit is prefixed with an underscore.
How null and mixed values become types
A null value becomes the null type, a number always maps to number (JSON has no separate integer type), and an array holding several value types becomes a parenthesised union such as (number | string)[]. Because the input is a sample, generated types match what the JSON actually contains — they do not guess at fields that were missing from the data.
Generation is fully local
The conversion is plain string building inside this tab and makes no network request, so it works offline and your JSON is never uploaded. The output is offered as a .ts download when you want to save it, alongside the code view in the workbench.
Questions
How are nested types named?
Each nested object gets a PascalCase name built from its parent name plus the key, e.g. an "address" key under Root becomes RootAddress. Array element objects get an "Item" suffix.
What happens with null or mixed values?
A null value becomes the null type; an array holding several value types becomes a parenthesised union such as (number | string)[].
Are numbers split into int and float?
No. JSON has one number type, so every number becomes number.
Related tools
See categoryJSON to JSON Schema
Infer a JSON Schema (draft 2020-12) from a JSON sample, with required and additionalProperties control.
JSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
YAML to JSON
Convert YAML to JSON locally, with indent choice and optional key sorting.