// the find
mholt/json-to-go
Translates JSON into a Go type in your browser instantly (original)
A single-file JavaScript library (and browser tool) that converts JSON into Go struct definitions. It's been around since ~2014 and is the canonical tool for this task — most Go developers have used it at least once when integrating with an external API.
The core logic is a single self-contained JS file you can drop into any toolchain or run with Node from stdin/stdout, which makes it easy to incorporate into codegen pipelines. It handles edge cases like mixed float/int arrays, duplicate top-level struct names, and deeply nested objects — the test suite covers these explicitly. Matt Holt wrote it, and he also wrote Caddy, so it's not abandonware despite infrequent commits. The browser version works offline and has no dependencies to rot.
It only looks at the first element of an array to infer types, so heterogeneous arrays will silently produce wrong types — the README admits this but it still bites people. There's no support for generating JSON struct tags beyond the basic `json:"field"` format: no `omitempty`, no custom tag strategies, no yaml/db/bson tags. The output isn't `go fmt` formatted, which is a minor but real annoyance. For anything beyond flat or moderately nested JSON — think deeply polymorphic API responses — you'll hit its limits fast and end up editing the output anyway.