Skip to the tool
GigaJSON

JSON to Go

All tools
Format and check
View and query
Convert
JSON to code
Encode and decode
Sample files
Guides Open GigaJSON
Input JSON
Output CODE

The CODE output appears here as you type.

Ready Runs in your browser

Paste an example, like an API response or a config file, and get Go structs with json tags. Each nested object gets its own type, and lists of records are merged, so a field that only some items have comes out optional. Other languages: Rust, Python, Java, C#, Kotlin, Swift, Dart, Zod, and TypeScript.

How to use it

  1. Paste JSON or open a file. A list of several records gives the best types.
  2. The Go code appears as you type.
  3. Copy it into your project or download it.

Private, local processing

This tool runs in your browser, in a background worker: nothing you paste or open is uploaded, and nothing is kept after you leave. For a list, types come from its first 1,000 items, which can be up to 5 MB of JSON. Already loaded features keep working if your connection drops. Loading another tool or jq for the first time needs a connection. When one tool isn't enough, GigaJSON opens your data with a tree, a table, JSONPath/JMESPath/jq queries, transforms, diff and history.

Questions

How are optional fields detected?

A key missing from some items becomes a pointer with omitempty (*string `json:"email,omitempty"`), and a value that is sometimes null becomes a pointer.

Which JSON library does the code use?

The structs work with encoding/json from the standard library: json.Unmarshal(data, &root).

Can I use a large file?

Yes. The file is read in a background worker, and the types come from the first 1,000 items of a list, which is plenty to find every field. That sample can be up to 5 MB of JSON.

What generates the code?

quicktype, the open-source generator (Apache 2.0), running in your browser. Check the result before you rely on it: a value that is always 0 in your examples is typed as a whole number, even if real data can have decimals.

Is my data uploaded?

No. The code is generated in your browser, so nothing you paste or open goes to a server, and nothing is kept after you leave the page.

All tools