JSON to Go
Paste JSON and get Go structs with json tags, int64 numbers, pointers for optional fields and Go-style names (ID, URL). Free and private.
JSON
Go
How the Go structs are built
- Every field gets a
json:"…"tag with the original key, so renamed fields likecreated-at→CreatedAtstill decode. - Keys missing in some array items become pointers with
omitempty, so you can tell "missing" from "zero". - Whole numbers become
int64, so big IDs fit. Common initialisms follow Go style:id→ID,url→URL. - Values that are only ever
null, or mix types, becomeany.
Decode JSON into the struct
var data Root
if err := json.Unmarshal(body, &data); err != nil {
log.Fatal(err)
}
fmt.Println(data.Title)Smart type detection
Objects inside arrays are merged into one type, so a key that appears in only some items is still included (as optional). Names come from the keys, and plural keys become singular: comments → Comment. Whole numbers and decimals in the same field become a decimal type. Everything runs in your browser; your JSON is never uploaded.
More free tools
JSON to TypeScriptGenerate TS interfaces from sample data.JSON to PythonPydantic models or dataclasses from JSON.JSON to JavaJava records or POJOs with Jackson annotations.JSON to C#C# classes for System.Text.Json.JSON to RustSerde structs from sample JSON.JSON ViewerTree view, search, copy path. Handles huge files.JSON FormatterBeautify or minify JSON in one click.JSON ValidatorClear errors with exact line and column.