JSON to Go
Generate Go structs from a JSON sample, with json tags carrying the original key names, omitempty for keys that are sometimes absent, and pointer types for fields the sample shows as null. Nested objects become named struct types.
JSON
Go
Result will appear hereReady. Press Generate or Ctrl+Enter.
How to use the JSON to Go
- Paste a JSON sample.
- Set the root struct name.
- Press Generate and copy the code.
Example
The null notes field becomes a pointer type.
{
"name": "json-utils",
"version": "1.0.0",
"private": false,
"tags": ["json", "tools"],
"author": { "name": "Ada", "active": true },
"score": 9.5,
"notes": null
}Frequently asked questions
Why pointers for null fields?
A pointer distinguishes an absent or null value from a zero value, which matters for patch style payloads.
Which numeric types are used?
Whole numbers become int64 and decimals float64, matching encoding/json behavior for unknown ranges.