Consuming a JSON API in Go
Paste a sample response and get the struct with json tags ready for encoding/json to decode into.
Generate Go structs from a JSON sample in your browser, complete with json struct tags.
Maintained by Roshan.
Converts json sample to go struct in this tab, with nothing sent anywhere.
Find related browser-local tools for nearby tasks without starting another search.
Browse all generatorsGo's static typing means consuming a JSON API starts with declaring a struct that matches it, and doing that by hand is fiddly - every field needs both an exported Go name and a json tag mapping it back to the original key. Generating the struct from a sample handles both at once: paste the JSON, get the struct with its tags already written. This infers the shape recursively, giving each nested object its own struct, and applies Go's conventions automatically - exported PascalCase field names paired with json tags carrying the original lower-case keys, so encoding and decoding round-trip correctly. The result is a working struct you can paste into a Go file and refine, rather than a skeleton you fill in field by field.
Paste a sample response and get the struct with json tags ready for encoding/json to decode into.
Generate the struct from an example config, then narrow numeric types and mark optional fields.
Yes. Every field carries a json tag with the original key, so decoding round-trips correctly.
JSON has one number type. float64 is the safe default; narrow to int where you know the value is whole.
Yes. Each becomes its own named struct referenced by the parent.
Go uses zero values for missing fields. Add pointer types yourself where a field is genuinely optional.
Generate TypeScript interfaces from a JSON sample in your browser. Nested objects become their own interfaces.
Generate Rust structs from a JSON sample in your browser, deriving Serialize and Deserialize.
Generate Python dataclasses from a JSON sample in your browser, with type hints.