JSON to TypeScript Converter
What does this tool do?
JSON to TypeScript conversion generates TypeScript interface or type definitions from a JSON object. Instead of manually writing types for API responses, configuration structures, or data models, you paste the JSON and get ready-to-use TypeScript types. This saves significant time when working with third-party APIs that don't provide TypeScript definitions, when receiving JSON from legacy systems, or when setting up TypeScript types for existing JavaScript codebases. The converter infers types from values β strings, numbers, booleans, arrays, nested objects, and null β and generates nested interfaces for complex structures.
How to Use
-
Paste your JSON object or array into the input box.
-
The TypeScript interfaces are generated instantly.
-
Customise the root interface name if needed.
-
Toggle between 'interface' and 'type' output style.
-
Copy the TypeScript definitions and paste them into your project's types file.
This JSON to TypeScript converter runs entirely in your browser β no data is sent to any server. Handles nested objects, arrays of objects, union types for mixed arrays, and optional fields. Useful for quickly typing API responses, database query results, and configuration objects.
Frequently Asked Questions
What is the difference between TypeScript interface and type? Both describe object shapes in TypeScript. Interfaces are extensible with declaration merging and work well for object types and class contracts. Types are more flexible β they can also represent union types, intersection types, and mapped types. For simple object shapes, both work equally well.
How are null values handled? If a JSON value is null, the TypeScript type is generated as null or the value's expected type. If you know a field can be null or a string, it becomes string | null. Review nullable fields and adjust types based on your actual API contract.
What if my JSON has inconsistent key names or optional fields? The converter generates types based on the provided sample. If some fields are sometimes absent, manually add ? after the field name to mark them optional (e.g. email?: string). Run the converter on multiple example JSON responses and merge the resulting types for the most complete interface.
Keywords: JSON to TypeScript, JSON to TS, JSON to interface, TypeScript type generator, JSON type inference, TypeScript interface from JSON