What this tool does
A JSON sample becomes Go structs, one per object.
{ "id": 1, "firstName": "Ada", "address": { "city": "Paris" } }
type Root struct {
Id int `json:"id"`
FirstName string `json:"firstName"`
Address Address `json:"address"`
}
type Address struct {
City string `json:"city"`
}
Columns are aligned the way gofmt aligns them — name, type, tag. Nobody reads unformatted Go, and pasting this into a file then running gofmt should change nothing.
That alignment is recent: fields used to come out separated by single spaces. It was a small thing, and it was still the output not looking like the language it claims to be.
Names are exported, keys live in the tag
encoding/json ignores unexported fields entirely: a lowercase field decodes nothing and encodes nothing, without a word. So every field is exported — PascalCase, with an F in front when the key starts with a digit (2fa gives F2fa) — and the tag carries the original key unchanged.
Two keys that produce the same Go name — user-name and userName — are kept apart by a numbered suffix. The tags stay distinct, so both fields still map to their own key.
omitempty omits more than you might think
The option adds ,omitempty to every tag. It applies when encoding only, and it cannot distinguish “absent” from “zero”: 0, "", false, an empty slice and a nil map all vanish from the output.
That is fine for an optional filter, and wrong for a score that can legitimately be zero. Where the difference matters, the usual answer is a pointer — *int — which encodes null for nil and a real 0 otherwise.
Types, and what a sample cannot say
- Integers become
int, notint64. On every 64-bit platform that is the same thing; a value beyond it fails loudly at decode rather than silently truncating. nulland unknown values becomeany. An empty array becomes[]any, a mixed array too, except when it mixes integers and floats —[]float64covers both.- No field is a pointer and none is optional, because a sample cannot show that. A key that is sometimes missing is a
*Tyou add yourself, and it is the first thing worth checking against a second payload.
Private by design
Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.