JSON to TypeScript
Paste a JSON object or array and instantly generate clean TypeScript interfaces. Types are inferred, nested objects become their own interfaces, and keys across arrays are merged — all in your browser.
Everything runs in your browser — your JSON is never uploaded to a server.
Understanding the JSON to TypeScript
Convert JSON objects and arrays into clean, typed TypeScript interfaces instantly. This free tool parses your JSON in the browser and generates properly structured interfaces with inferred types, creating separate named interfaces for nested objects and intelligently merging keys across array elements. It's essential for developers who want to add type safety to JSON data without manual interface writing. Everything runs client-side — your JSON never touches a server.
How it works
The tool uses native JSON.parse() to validate and parse your input, then walks the entire structure to infer TypeScript types: strings, numbers, booleans, and nulls map to their literal types, while objects and arrays generate interfaces. For nested objects, the tool extracts the key name, converts it to PascalCase, and creates a named interface; the parent references it by name. For arrays of objects, all keys are merged into a single interface, keys missing from some elements are marked optional (with ?), and differing value types are combined into unions. The output is formatted as exportable TypeScript interfaces.
Worked example
Input: {"id": 1, "name": "Alice", "tags": ["dev", "lead"], "meta": {"active": true}}. Output: Two interfaces — Root with fields id: number, name: string, tags: string[], meta: Meta; and Meta with active: boolean. The nested object becomes its own reusable interface, and primitive arrays are typed as string[].
Tips & common mistakes
- Use a descriptive root name (e.g., 'User' instead of 'Root') to get better child interface names — the singular form is automatically extracted from array field names like 'posts' → Post.
- For arrays with inconsistent objects (some missing keys, different types per key), all keys appear in the merged interface with optional markers and union types — this is intentional and safe.
- Empty objects {} become Record<string, unknown>, and empty arrays [] become unknown[] — provide sample data to get concrete types.
- Keys with special characters or starting with numbers are automatically quoted (e.g., "2fa": string) to produce valid TypeScript.
- Copy the output directly into your .ts file or download as a .ts file; all interfaces are exported and ready to use.
- If the root JSON is an array, the generated Root interface describes the merged shape of all array elements, not the array itself.
Related tools
Frequently Asked Questions
Does it handle nested objects?
Yes. Each nested object becomes its own named interface (PascalCase from the key) and is referenced by name from its parent, so you get a clean, reusable set of interfaces instead of one deeply inlined type.
How are arrays of objects handled?
The keys of every object in the array are merged into a single interface. Keys that appear in some elements but not others are marked optional with a question mark, and differing value types are combined into a union.
Is my JSON sent anywhere?
No. The interfaces are generated entirely in your browser with JavaScript. Your JSON never leaves your device and nothing is uploaded to a server.