Generate Go structs with JSON tags from a sample. Free, private, runs in your browser.
100% private — your files never leave your browser. All processing happens locally on your device.
Go's strong typing rewards explicit struct definitions. Having to handwrite a 40-field struct for an API response is tedious and error-prone. This tool does the tedious part: paste a sample response and get a struct with PascalCase exported field names, correct Go types, and `` `json:"..."` `` tags matching the original JSON keys. The result is ready to drop into any Go project — no dependencies beyond the standard `encoding/json` package.
Nested JSON objects become named sub-structs referenced from the parent field. `{"addr":{"city":"NYC"}}` yields a `Root` struct with an `Addr Addr` field and an `Addr` struct with a `City string` field. JSON arrays become Go slices (`[]string`, `[]int`). Null values in the sample yield `*interface{}` with `omitempty` on the json tag — the pointer captures the nullable-ness, and `omitempty` ensures JSON output doesn't include the field when the pointer is nil.
JSON has one number type; Go has many. The tool defaults to `int` for whole numbers and `float64` for numbers with a fractional part. If you need `int32` or `int64` for protocol-level reasons, adjust by hand after generation — the inference is heuristic, not protocol-aware. For unsigned integers, timestamps, or fixed-precision decimals, use the generated struct as a starting point and tune the types to match your storage layer.
Go convention is PascalCase for exported struct fields. JSON convention is often snake_case or camelCase. The tool converts aggressively: `user_name` → `UserName`, `emailAddress` → `EmailAddress`. The original key is preserved on the `json` tag so marshalling produces the exact key your JSON source expected. If the original key was invalid Go (e.g., started with a digit), the tool prefixes an underscore to keep the generated code compilable.
Yes. JSON keys like `user_name` become `UserName` on the struct; the original key is preserved in the json tag (`` `json:"user_name"` ``). This matches idiomatic Go exported-field conventions.
Null values in the sample JSON emit `*interface{}` with `omitempty`. When you have a more specific sample (e.g., `"count": null` or `"count": 3`), consider tweaking the emitted pointer type to `*int`.
Whole numbers become `int`; numbers with a fractional part become `float64`. If you need a specific width (`int32`, `int64`, `uint`), adjust after generating.
Yes. `["a","b"]` becomes `[]string`. Heterogeneous arrays fall back to `[]interface{}`.