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 valueTypeScript type
"hello"string
42 / 3.14number
true / falseboolean
nullnull
["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.

How to use

  • Paste a JSON sample — TypeScript interfaces generate instantly.
  • Nested objects become separate interface declarations.
  • Copy the output and paste it into your TypeScript project.
  • Rename interfaces and adjust union types as needed for your data model.