About JSON to Types

JSON to Types infers a type from a representative JSON value and renders it as TypeScript interfaces or Go structs. Arrays of objects are merged into one shape, and a field missing from some items is marked optional.

It runs in the page. Nothing is uploaded.

How to use it

  1. Paste a JSON value.
  2. Choose TypeScript or Go and set the root type name.
  3. Copy the generated types.

Common questions

How are optional fields detected?

If a key appears in some array items but not others, it becomes optional: a ? in TypeScript, a pointer with omitempty in Go.

What about null?

A null seen alongside a value produces a nullable type, like number | null.

Are nested objects named?

Yes. Each nested object gets its own interface or struct, named from its key.

Is my JSON uploaded?

No. The inference runs in JavaScript in the open tab.