JSON to TypeScript
Generate TypeScript interfaces from JSON data instantly
Generated TypeScript will appear here... How to Use
- Paste your JSON — drop any valid JSON object or array into the input field.
- Adjust the options — set the root type name, choose interface or type output, and toggle the export keyword.
- Read the result — TypeScript declarations are generated instantly as you type, with nested objects extracted into their own named interfaces.
- Copy the code — click Copy to paste the result straight into your project.
Features
- Nested interfaces — nested objects become separate, PascalCase-named interfaces derived from their property path
- Smart arrays — element types are unified; mixed arrays produce union types and object arrays are merged with optional keys
- Shape reuse — identical object shapes share a single interface instead of being duplicated
- interface or type — generate either declaration style, with or without the export keyword
- Invalid JSON detection — clear error messages tell you exactly why the input failed to parse
- 100% client-side — No data leaves your browser.
Use Cases
- API integration: paste a sample API response and get ready-to-use TypeScript types for your fetch calls
- Legacy migration: convert existing JSON config files or mock data into typed structures when moving a project to TypeScript
- Documentation: generate accurate type definitions to document webhook payloads or event schemas
- Prototyping: quickly scaffold types while exploring a new data source before writing validation schemas
Related Tools
- JSON Formatter — format, validate, and beautify JSON before converting it.
- JSON Schema Generator — infer a JSON Schema from your data for runtime validation.
- YAML Converter — convert YAML configs to JSON first, then generate types.
Frequently Asked Questions
What is the difference between interface and type output?
Interfaces are the classic way to describe object shapes in TypeScript and support declaration merging, while type aliases are more flexible and can also represent primitives, arrays, and unions. Use the toggle to switch between interface and type output — both describe the same structure.
How are arrays with mixed values handled?
The tool inspects every array element and unifies their types. If all elements share one type you get T[]; mixed elements produce a union such as (string | number)[]. Arrays of objects are merged into a single interface, and keys missing from some elements become optional.
Is my JSON data sent to a server?
No. All conversion runs entirely in your browser using client-side JavaScript. Your JSON never leaves your device, so it is safe to paste private API responses or configuration data.