Unicorn

JSON to Go Struct

Paste a JSON sample to get Go structs: field names are exported while the wire spelling is kept in a json tag, nested objects become named structs, arrays become slices, and a field that shows two different types falls back to any with a note so you look at it. Numbers follow int64 and float64, and the whole result lands in one file you can drop into a package.

How to use

Generate exported Go structs with json tags from a JSON sample. Your data is processed only inside this browser tab.

FAQ

Why wrap keys in json tags?

encoding/json only fills exported fields, so the field name goes idiomatic while the tag preserves the real payload key.

What happens to a field with two types?

It becomes any and is listed in the note above the output, because that usually means the sample is incomplete.

Related tools