JSON → Go structs
ClientInfer struct fields and nested types from one JSON sample; adjust numeric types and pointers before production use.
Review before copying into Go
The generated structs help you start quickly, but a single sample cannot prove optionality, integer ranges, date formats, or union shapes. Review pointers, tags, package names, and validation before the type reaches production code.
Learn more: JSON and Go
Emit `struct` types with `json` tags from one sample—similar to the C# and Java generators, oriented toward encoding/json.
Types
Numbers map to float64 by default; tighten to int64 or custom types where your API guarantees them. Nested objects become nested struct types with inferred names.
JSON → Go
?
Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.
Rename types, use pointers or nullable types where needed, and align tags with your JSON encoder/decoder.
Nearby workflows on Toolcore
- JSON → Rust — when another systems language needs serde-shaped structs.
- JSON Schema validate — before you commit generated json tags as the API contract.
- JSON formatter — to normalize the sample object before inference.
Common use cases
- Scaffold structs with json tags for encoding/json from a captured API response.
- Compare inferred field types against your server’s actual structs during migrations.
- Drop starter types into a Go module before refining pointers and omitempty tags.
- Turn a webhook or third-party API example into a first-pass request or response type before writing tests.
- Review nested JSON and decide which structs should be exported, embedded, or kept package-private.
Common mistakes to avoid
Using float64 for every number
Samples may not show integers vs floats correctly. Switch to int64 or custom types when semantics matter.
Forgetting omitempty for optional API fields
Generator hints at shape; optional presence still follows your API contract—adjust tags before encoding.
Confusing missing values with zero values
Go zero values can hide whether a field was absent. Use pointers, custom unmarshalling, or validation when absence matters.
Assuming every array is homogeneous
The output follows the sample shape. If real payloads mix item shapes, review the generated slice element type before relying on it.
FAQ
Is struct generation local?
Yes. JSON is parsed and code is emitted entirely in your browser.
Does output include validation?
No. It suggests types and tags. Add validation and error handling in your Go code.
Should optional fields be pointers?
Often yes when you must distinguish missing, null, and zero values. The generated struct is a starting point; choose pointers or custom types based on the API contract.
Does it support custom unmarshalling?
No. It emits simple struct scaffolding for encoding/json. Add custom UnmarshalJSON methods when dates, numbers, or unions need special handling.
More tools
Related utilities you can open in another tab—mostly client-side.
JSON → Kotlin data classes
ClientKotlin data classes from sample JSON—nested types from one example, local only.
JSON → Swift structs (Codable)
ClientSwift structs with Codable and CodingKeys from sample JSON—local only.
JSON → Python TypedDict
ClientTypedDict scaffolding from sample JSON—nested shapes inferred in the browser.
YAML ↔ JSON
ClientYAML to JSON and JSON to YAML online—bidirectional converter, format either side in the browser.