/tools/json-to-go
JSON to Go Struct Generator
Convert JSON into typed Go structs with nested declarations, JSON tags, and evidence-based optional fields.
JSON sample
Go structs
/usage
How to convert JSON to Go structs
- Paste a representative JSON object or array, drop a file, or load the sample.
- Name the root type and Go package, then choose pointer and
omitemptybehaviour. - Generate, review the inferred field semantics, and copy or download the
.gosource.
/inference
Struct inference across complete JSON samples
Nested objects and arrays
Every object in an array contributes to one merged shape. A field becomes optional only when it is absent from at least one observed object, rather than because the first item happened to omit it.
Idiomatic Go names and tags
Fields are exported, common initialisms such as ID, URL, and API are preserved, name collisions are resolved, and original JSON keys remain in struct tags.
Numbers, null, and mixed values
Whole numbers become int64 and decimals become float64. Nullable concrete values can use pointers; null-only or genuinely mixed values use any with a visible warning.
Bounded local processing
A dedicated worker builds a compact type graph without cloning the parsed payload. Input, traversal, schema, depth, and output limits prevent unbounded work and the worker is released after use.
/faq
JSON to Go questions
Is my JSON sent to a server?
No. Parsing, schema inference, and Go emission run inside your browser. Data Demon does not receive the input or generated code.
Will the generated Go compile without review?
The output is syntactically structured Go, but inference cannot know your domain rules. Review nullability, numeric ranges, time formats, validation, and whether any should become a domain type.
Why does an empty array become []any?
An empty array contains no evidence about its element type. Add a representative item to the JSON sample or replace any after generation.