JSON to TypeScript Interface Converter

BeanTrans transforms JSON and JSON5 objects into cleanly formatted TypeScript interfaces directly in your browser. It infers primitive, union, and array types, splits nested objects into named interfaces, and never sends your payload to any server.

Key Capabilities

  • Extracts nested JSON objects into reusable exported TypeScript interfaces.
  • Supports JSON5 inputs (comments, trailing commas, single quotes) as well as strict JSON.
  • Toggle optional/nullable fields and 2-space or 4-space indentation inside the Config drawer.

Type Mapping Reference

Source Target Notes
stringstringTypeScript primitive string
numbernumberInteger and float unified
booleanbooleanTS boolean
nullT | nullNullable union type
array<T>T[]Typed array notation

Frequently Asked Questions

Does BeanTrans support JSON5 syntax like comments and trailing commas?
Yes. The JSON parser uses JSON5 under the hood, so you can paste object literals with comments or trailing commas directly.
Can I switch between 2-space and 4-space indentation for TypeScript?
Yes. Open the Config drawer at the bottom and set Indent to 2 spaces or 4 spaces.
Can I also convert Java, Go, or SQL DDL into TypeScript interfaces?
Yes. Change the left Source selector to Java, Go, Python, Rust, Kotlin, Protobuf, or SQL DDL while keeping Target set to TypeScript.