JSON → TypeScript Interface
Generate TypeScript interfaces automatically from any JSON object. Handles nested objects, arrays, nullable values, and optional fields. Paste JSON and get ready-to-use TypeScript.
How to use
- 1 Paste any JSON object (or click "Load example") into the input field on the left.
- 2 Set an interface name, choose whether fields should be optional, and toggle semicolons.
- 3 The TypeScript interface generates instantly on the right. Click "Copy TypeScript" to use it.
Key features
- Generates TypeScript interfaces instantly from any JSON object with no configuration needed
- Handles nested objects: creates separate named interfaces for each nested level
- Supports arrays, null values, booleans, numbers, and strings with correct TS types
- Optional fields toggle: adds ? to all properties for flexibility
- Semicolon toggle and custom interface name. Copy with one click
What is JSON to TypeScript?
This tool converts any JSON object into TypeScript interfaces automatically. Paste a JSON response from an API, a configuration file, or a mock dataset and get a fully typed TypeScript interface, with correct types for strings, numbers, booleans, arrays, nested objects, and nullable values.
TypeScript interfaces provide compile-time type safety for your data. Instead of manually writing types for every API response or JSON config, this generator does the mapping for you. It handles deeply nested structures by creating separate named interfaces for each level, keeping your code clean and maintainable.
Common Use Cases
Typing API responses
Fetch JSON from an API endpoint and generate a TypeScript interface that matches the exact response shape. Update it whenever the API contract changes.
Configuration files
Convert JSON config files (package.json, tsconfig, ESLint) into TypeScript interfaces for type-safe configuration in your codebase.
Mock data generation
Generate interfaces from mock JSON data to ensure your test fixtures always match the expected types. Catch type mismatches before they reach production.
Migrating JS to TypeScript
When converting a JavaScript project to TypeScript, use this tool to generate interfaces from your existing JSON structures and API contracts.
OpenAPI / Swagger schemas
Extract example JSON responses from your OpenAPI specs and convert them directly to TypeScript interfaces for your frontend SDK.
Rapid prototyping
Sketch a JSON structure and instantly get the corresponding TypeScript types. Iterate on the data shape and regenerate interfaces as you go.
JSON to TypeScript Type Mapping
How each JSON value type is converted to a TypeScript type.
| JSON Type | Example | TypeScript Type |
|---|---|---|
| string | "hello" | string |
| number | 42 | number |
| boolean | true | boolean |
| null | null | null | undefined |
| array | [1, 2, 3] | number[] |
| object | {"key": "val"} | InterfaceName |
Frequently Asked Questions
How do I convert JSON to TypeScript interface?
Paste any valid JSON object into the input field, set an optional interface name, and the TypeScript interface will generate instantly on the right. Click "Copy TypeScript" to use it in your project. No configuration or setup needed: it works directly in your browser.
Does it handle nested JSON objects?
Yes. The generator creates a separate named TypeScript interface for each nested object level. For example, if your JSON has a user.address field, it will generate both a User and UserAddress interface with the correct relationship between them.
What happens with nullable or optional fields?
Null values in JSON are mapped to null | undefined in TypeScript. You can also toggle the "Optional fields" option to add a ? modifier to all properties, making them optional. This is useful when working with partial API responses or form data.
How are arrays handled?
Arrays are converted to TypeScript array types based on their content type: string[], number[], boolean[], or InterfaceName[] for arrays of objects. The generator inspects the first element to determine the array member type.
Is my data sent to a server?
No. Everything runs in your browser locally. Your JSON data never leaves your machine. This makes it safe to use with sensitive data, internal API responses, or proprietary JSON structures.