ToolBark
Developer

JSON to TypeScript Interface

Turn any JSON object into clean TypeScript interfaces instantly

4 interfaces26 lines

Tips

  • Nested objects become their own named interfaces, inferred from the key name.
  • Arrays of objects produce an Item interface for the element type.
  • Mixed-type arrays produce a union type, e.g. (string | number)[].
  • Enable Optional props if your data may have missing fields.
About

Stop writing TypeScript interfaces by hand. Paste any JSON object into our free JSON to TypeScript interface generator and get accurate, ready-to-use TypeScript interfaces in seconds. Nested objects become their own named interfaces, arrays produce correct element types, and options like optional props, readonly, and export keywords let you match your codebase style exactly.

FAQ
How does the tool handle nested JSON objects?+

Each nested object is converted into its own named TypeScript interface, with the name derived from the parent key converted to PascalCase. For example, a key called "address" produces an Address interface that is referenced from the parent interface.

What happens with mixed-type arrays?+

If an array contains elements of different types (e.g. strings and numbers), the tool generates a union type such as (string | number)[]. Arrays of objects produce a dedicated Item interface for the element shape.

Can I make all properties optional?+

Yes. Enable the "Optional props (?)" checkbox and every property will be marked with ? — useful when your JSON data may have missing fields or when modelling partial API responses.

Does the tool work with root-level JSON arrays?+

Absolutely. If your JSON starts with an array, the tool infers the element type, generates any needed interfaces, and produces a type alias for the root array such as type Root = RootItem[].

Related tools