JSON 转 Go Struct 生成器

将 JSON 转换为带 json tag 的 Go struct,支持嵌套对象和数组。

Struct 名称:
JSON0 字符
Go Struct

What Is JSON to Go Struct Generator?

JSON to Go Struct Generator is a free online tool that converts a JSON object into idiomatic Go structs with proper json struct tags. It saves Go developers time when working with REST APIs, configuration files, or any data that needs to be unmarshaled with encoding/json.

How to Use JSON to Go Struct Generator

  1. Paste your JSON into the left panel, or click Load Sample to try an example.
  2. Set the root struct name (defaults to Root).
  3. The generated Go structs appear instantly in the right panel.
  4. Click Copy to copy the result to your clipboard.

Features

  • Generates Go structs with json struct tags for all fields
  • Recursively handles nested objects as separate structs
  • Maps JSON types to Go types: string, bool, int64, float64, slices
  • Null fields mapped to interface
  • Field names automatically converted to PascalCase
  • Runs entirely in your browser — zero data uploaded

FAQ

What Go types are generated from JSON values?

JSON strings become string, booleans become bool, integer numbers become int64, floating-point numbers become float64, arrays become slices, objects become nested structs, and null becomes interface{}.

Are json tags added automatically?

Yes. Each field includes a `json:"fieldname"` struct tag that matches the original JSON key, so encoding/json can marshal and unmarshal correctly.

How are nested objects handled?

Nested JSON objects are converted to separate Go structs. The parent struct references the child struct by its PascalCase name derived from the field name.

Is my data sent to a server?

No. All conversion happens entirely in your browser. Your JSON data never leaves your device.