What is JSON to TypeScript?
JSON to TypeScript conversion is the process of generating strongly-typed TypeScript interfaces or type aliases from raw JSON data. Instead of manually writing type definitions for API responses, configuration files, or database records, you can paste the JSON and instantly get accurate TypeScript types. This saves time, reduces typos, and ensures your types match the actual data shape. Everything runs in your browser — your data never leaves your device.
Why Use TypeScript?
TypeScript adds static type checking to JavaScript, catching bugs at compile time rather than runtime. With proper type definitions, your editor provides autocompletion, inline documentation, and refactoring support. TypeScript is used by teams at Microsoft, Google, Airbnb, Stripe, and thousands of open-source projects. Defining interfaces for your JSON data is one of the most impactful ways to leverage TypeScript's power.
How Type Inference Works
This converter parses your JSON and walks the object tree recursively. For each value it encounters, it infers the TypeScript type: strings become string, numbers become number, booleans become boolean, and null becomes null. Nested objects get their own named interface using PascalCase of the parent key. Arrays are inspected element-by-element: arrays of objects merge all objects' keys into a single interface, with optional markers for keys that don't appear in every element.
Interface vs Type in TypeScript
| Feature | interface | type |
|---|---|---|
| Declaration merging | Yes (open) | No (closed) |
| Extends / implements | Yes | Intersections (&) |
| Union types | No | Yes (A | B) |
| Mapped types | No | Yes |
| Best for | Object shapes, public APIs | Unions, utility types |
How to Use
Paste JSON
Paste a JSON object or array from an API response, config file, or database query.
Configure options
Set the root name, choose interface vs type, toggle optional, export, and readonly.
Review output
TypeScript interfaces are generated in real time with syntax highlighting.
Copy to project
Click Copy to grab the output and paste it directly into your .ts file.
Frequently Asked Questions
Yes, completely free with no limits. Convert as much JSON as you want. No account or signup required.
Absolutely. Everything runs in your browser using JavaScript. Your JSON data never leaves your device — nothing is uploaded to any server.
Interfaces are open and can be extended or merged. Types are closed and support unions and intersections. For object shapes they are mostly interchangeable. Use interfaces for public APIs and types for unions or utility types.
Each nested object gets its own interface named after the parent key in PascalCase. For example, an 'address' field becomes an Address interface. Deeply nested objects are handled recursively.
The converter merges all objects in the array to build a single interface with all possible keys. Keys that don’t appear in every object are marked as optional.
It adds a question mark (?) to every property in every interface, making them all optional. This is useful when working with partial data or PATCH endpoints.
Yes. The output is valid TypeScript. Copy it directly into a .ts or .d.ts file. Use the 'Export interfaces' toggle to add export keywords if needed.
All standard JSON types: strings, numbers, booleans, null, arrays, and nested objects. The converter also handles arrays of mixed types and null values.
Null values are typed as 'unknown | null' since the actual type cannot be inferred from null alone. Replace 'unknown' with the expected type in your code.
The readonly modifier is applied to all properties at every nesting level. This prevents accidental mutation of deeply nested data structures.