JSON to TypeScript
Paste a JSON sample and get TypeScript interface declarations — nested objects, arrays, and null handled automatically. Runs entirely in your browser.
Type mapping
| JSON value | TypeScript type |
|---|---|
| "hello" | string |
| 42 / 3.14 | number |
| true / false | boolean |
| null | null |
| ["a", "b"] | string[] |
| [{"id": 1}] | TypeName[] |
| {"key": val} | interface TypeName { ... } |
| [] | unknown[] |
Frequently Asked Questions
How does the type inference work?+
The converter parses the JSON and walks each value recursively. string values become string, numbers become number, booleans become boolean, null becomes null, arrays produce T[] where T is inferred from the first element, and objects become named interfaces. If a value could not be inferred (e.g., empty array), it becomes unknown[].
What if my array contains items of different types?+
The converter infers the type from the first array element. For heterogeneous arrays like [1, "foo", null], the output will be number[] based on the first element. You can manually update the type to (number | string | null)[] after copying.
How are interface names determined?+
Interface names are derived from the JSON key names converted to PascalCase. The root object becomes Root. A nested object at key "userProfile" becomes UserProfile. A key "user_address" becomes UserAddress.
Is my JSON sent to a server?+
No. All conversion runs entirely in your browser using JavaScript. Your JSON never leaves your device.
Related Tools
How to use
- Paste a JSON sample — TypeScript interfaces generate instantly.
- Nested objects become separate
interfacedeclarations. - Copy the output and paste it into your TypeScript project.
- Rename interfaces and adjust union types as needed for your data model.