loot.tools

JSON to Go Struct

Paste a JSON object or array and get a Go struct definition with json tags generated automatically. Nested objects become inline structs, arrays become slices, and field names are converted to exported Go names with common initialisms capitalized.

Paste JSON to generate a Go struct with json tags. Nested objects become inline structs and arrays become slices.

JSON Input
Go Output

What this tool does

Paste JSON and get a ready-to-use Go struct back. Each key becomes an exported field with a json tag carrying the original name, so encoding/json round-trips your data without extra config. Nested objects turn into inline structs and arrays turn into slices of the right element type.

Why you'd use this

Hand-writing structs to unmarshal an API response is slow and easy to get wrong, especially with deeply nested payloads. Drop the JSON here and get the struct in seconds. It saves you from counting brackets and guessing whether a number should be an int or a float64.

How field names and types are chosen

Keys like user_id or api-url become UserID and APIURL, following Go's convention of capitalizing common initialisms (ID, URL, API, HTTP, and so on). Whole numbers map to int, decimals to float64, true/false to bool, and strings to string. When a field shows different shapes across array elements, the output falls back to interface{} so it still compiles.