Converters
JSON to TypeScript
Generate nested TypeScript interfaces from example JSON. Name the root interface, infer array unions and choose optional fields.
Ready to run. Input limit: 1 MB characters.
Output
—
Output actions
Ready to copy output once your result appears.
JSON to TypeScript mini guide
Generate nested TypeScript interfaces from example JSON. Name the root interface, infer array unions and choose optional fields.
How to use JSON to TypeScript
- 1Paste representative example JSON, or choose Load sample.
- 2Set Root interface name and Make all fields optional.
- 3Select Convert, inspect the generated definitions, then copy or download them.
What it is good for
- • Create nested interfaces from API examples.
- • Infer optional fields across array records.
- • Name a root type for fixtures and prototypes.
Example
Input
{"name":"Alice","age":30}Output
export interface Root {
"name": string;
"age": number;
}Rules and limitations
Nested objects become named interfaces. Root interface name must be a valid identifier; generated nested names are normalized and made unique. JSON property names remain quoted so punctuation and spaces do not break the TypeScript declarations.
Array objects are inferred from all supplied examples. Properties absent from some object samples become optional, and mixed values become union types. Empty arrays produce unknown item types. Enable Make all fields optional when the examples represent partial updates.
Inference describes the sample, not your complete domain model. A single example cannot establish permitted enums, string formats, length limits or future variants. Supply diverse array samples and review the result against your API contract before relying on it.
Common problems
Valid JSON uses double quotes and excludes comments and trailing commas. A sample containing only an empty object or empty array cannot imply a useful detailed shape.
TypeScript output does not validate values at runtime. Use JSON Schema or another runtime validator where external data needs checking.
Frequently asked questions
Does this infer nested objects?
Yes. Nested shapes are inferred recursively.
Are missing sample fields optional?
Yes for object variants within arrays; fields absent from any corresponding sample are optional.
Can an example define the full contract?
No. Examples cannot prove all permitted values, formats or required business rules.
What happens to empty arrays?
Items have an unknown type in TypeScript or an unconstrained schema until you supply examples.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Continue with a practical guide
Convert nested JSON to CSV without losing fieldsChoose between flattened columns and JSON cells, preserve arrays and review missing values before exporting.
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
JSON Schema Generator
Generate JSON Schema from example JSON using Draft 2020-12 or Draft 7. Inspect inferred types and configure required or optional fields.
JSON Formatter
Format or minify JSON with configurable indentation.
JSON Compare Online
Compare two JSON blobs with structural diff.
JSON to CSV
Convert a JSON array of objects to CSV.