JSON to Go Struct
Generate Go structs with JSON tags from a JSON sample, including nested types.
Input
Result
How to use
Generate Go structs
Paste a representative JSON object and run Convert. Field types are inferred from the sample values.
- Paste a JSON object.
- Click Convert.
- Copy the generated Go code.
Type inference
Whole numbers become int, decimals become float64, booleans become bool, strings become string and nested objects become named structs.
Frequently asked questions
Why is a null field typed as interface{}?
A null value gives no type information, so the generator falls back to interface{}.
Does it handle arrays of objects?
Yes. Arrays become slices, and arrays of objects produce a nested struct type.
Related tools
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample with optional and union types.
JSON to C# Class
Generate strongly typed C# classes from a JSON sample in a single click.
JSON Flatten and Unflatten
Convert nested JSON into dot-notation keys and rebuild nested objects from flat data.
JSON Formatter
Beautify and validate JSON with configurable indentation, error highlighting and one click copy.
JSON Validator
Check whether your JSON is valid and see a clear explanation of any syntax problem.
JSON Minifier
Remove every unnecessary space and newline to produce the smallest possible JSON payload.