Search tools

Find a tool by name or what it does.

JSON to Go Struct

Paste JSON and get typed Go structs, with nested types, slices, json tags, pointers, and omitempty handled for you.

Structs are generated live as you type. Nothing leaves your browser.

Nested structs

Options

Go

Your Go structs will appear here.

How to convert JSON to a Go struct online

  1. Paste your JSON

    Drop a JSON object, array, or value into the input, and the matching Go structs appear live as you type.

  2. Name the root type

    Set the root type name to whatever suits your package, such as User, Response, or Config.

  3. Choose the shape

    Pick named or inline nested structs, and toggle pointers and omitempty so the output matches your conventions.

  4. Copy the struct

    Copy the generated Go to your clipboard or download it as a .go file.

Why use this tool

Named or inline nested structs

Every nested object becomes its own named struct, or stays inline inside the parent, whichever you prefer for the file.

Slices and element types

Arrays infer a single element type such as []string or []Post, mixed arrays collapse to []interface{}, and empty arrays fall back to interface{}.

Pointers for nullable fields

A field that is null in the sample, or missing from some items in a list, is treated as nullable and can be emitted as a pointer so absent stays distinct from zero.

json tags and omitempty

Each field carries a json tag that preserves the original key, and one toggle adds omitempty across every field.

Exported names and dedup

Keys become exported PascalCase field names with common initialisms like ID and URL uppercased, and identical object shapes are merged into one shared struct.

Runs entirely in your browser

Everything happens on your device. Nothing is uploaded, so private payloads and API responses stay local.

About this tool

This tool turns a JSON sample into ready to paste Go type definitions. It reads the structure of your data and infers a typed shape: strings become string, whole numbers become int, decimals become float64, and true or false becomes bool. Every object turns into a struct whose exported field names are the PascalCase form of your keys, and each field carries a json tag that preserves the original key so the value round trips cleanly through encoding and decoding.

It is built for the messy parts of real payloads. Nested objects become their own named structs, or stay inline when you prefer a single block. A field that appears in some list items but not others is treated as nullable, and with the pointer option on it becomes a pointer so an absent value stays distinct from a zero value. Arrays infer their element type, mixed and empty arrays fall back to interface{}, and repeated object shapes are collapsed into one shared struct so the output stays short. The omitempty toggle adds that tag option to every field when you want empty values dropped from the encoded result.

Everything is inferred from the sample you paste, so richer input gives a more precise result. Clean up a raw response first with the JSON formatter, or generate types for another language with JSON to TypeScript. Because it all runs in your browser, request bodies that mention internal services or tokens never leave your machine.

Frequently asked questions

How does it infer the Go types?
It reads a JSON sample and derives the shape from the values it finds. Objects become structs, arrays become slices, whole numbers become int, decimals become float64, and text and booleans become string and bool. The result updates live as you edit the input.
What is the difference between named and inline structs?
Named mode emits each nested object as its own top level struct and references it by name, which keeps deep data readable. Inline mode embeds each nested object directly inside its parent as an anonymous struct, so the whole shape lives in one block.
What do the pointer and omitempty options do?
Pointers wrap nullable fields, meaning fields that were null in the sample or absent from some list items, as pointer types so an unset value stays distinct from a zero value. omitempty adds the omitempty option to every json tag so empty fields are dropped when the struct is encoded.
How are mixed arrays, empty arrays, and invalid JSON handled?
An array whose elements differ in type, and an array with no elements, both fall back to interface{}. Objects with different keys in the same list are merged into one struct with the extra keys marked nullable. Invalid input shows an inline message instead of a broken result.
Is my data uploaded anywhere?
No. Everything runs in your browser. Your JSON never leaves your device, is never sent to a server, and is not stored or logged.

Related tools