Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsJSON to Go Struct Converter
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский

JSON to Go Struct Converter

dev

Turn a JSON sample into Go structs with json tags, int or float64, pointers and omitempty

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

Paste a JSON sample and get Go struct types with json tags, ready for json.Unmarshal. Whole numbers become int, int64 past 2,147,483,647, and any decimal makes a field float64; a value that is sometimes null becomes a pointer, and keys missing from some objects get omitempty.

Next:
  • JSON to TypeScript Generate TypeScript interfaces or types from a JSON sample
  • JSON Formatter & Validator Format, validate, minify and sort JSON with exact error positions

How to convert JSON to a Go struct

1

Paste a JSON sample, such as an API response, into the left box.

2

The Go types appear as you type: one struct per object, with json tags and Go-style names such as UserID.

3

Choose Inline nested structs or omitempty on every field if you want them, and set the root type name.

4

Press Copy, or Download to save a .go file, and add your package line.

About JSON to Go Struct Converter

Go decodes JSON into structs, and every field needs the right type and a json:"..." tag naming the key. This converter writes those types from a sample, so a 200-line API response becomes correct Go in one paste.

How types are chosen.

JSON value Go type
"text" string
true / false bool
42 (whole numbers only) int, or int64 beyond 32 bits
4.5 (any decimal seen) float64
null, and also a type a pointer, such as *string
only null, or mixed kinds any
[ ... ] a slice, such as []string
{ ... } a named struct, or an inline one

Arrays of objects. All the objects of an array are merged into one struct, so a field that appears in only some of them is still there, with ,omitempty in its tag. Two objects with exactly the same keys and types share one type name.

Names. Keys become exported Go names in Go style: user_id becomes UserID, avatar_url becomes AvatarURL, using golint's list of initialisms. A key that starts with a digit gets an N in front; two keys that make the same name are numbered. A key with characters a tag cannot hold, such as a comma, is marked with a comment, because encoding/json would not match it.

Options. Inline nested structs writes one type with anonymous structs inside, which suits a one-off response. omitempty on every field suits structs you also marshal. The root type is called Root unless you name it.

Every output was checked by reading the Go back and decoding the sample with encoding/json's rules. Nothing you paste leaves the browser.

Frequently asked questions

How do I convert JSON to a Go struct?

Paste a JSON sample into the converter and the Go struct appears beside it, with a json tag on every field and nested objects as their own types. Copy it into your package and decode with json.Unmarshal(data, &v), where v is a variable of the root type.

Should JSON numbers be int or float64 in Go?

Use int when every sample value is a whole number and float64 when any value has a decimal part, because encoding/json refuses to put 4.5 into an int. The converter chooses per field, and picks int64 when a whole number is beyond 2,147,483,647.

How are null values handled in Go structs?

A field seen both as null and as a value becomes a pointer, such as *string, so nil means null and an empty string stays different. A field that was only ever null becomes any, since the sample does not say what it would hold otherwise.

What does omitempty do in a json tag?

With omitempty, json.Marshal leaves the field out when it holds the zero value: an empty string, 0, false, nil or an empty slice. The converter adds it to keys missing from some objects of an array, and a switch adds it to every field.

Why is the field called UserID and not UserId?

Go style, checked by golint and most linters, writes initialisms in capitals: ID, URL, HTTP, API, JSON and about forty more. The json tag keeps the original key, user_id or userId, so decoding still matches the API exactly.

Is my JSON uploaded?

No. The conversion runs in your browser with no request to any server, and the JSON is not stored, so API responses holding tokens or personal data stay on your device. Close the tab and nothing remains.

Sources

  • The Go Programming Language Specification, Struct typesField declarations, identifiers and tags
  • Go standard library, encoding/jsonTag syntax, omitempty, how numbers and null decode
  • golint, lint.go (commonInitialisms)The initialisms written in capitals: ID, URL, HTTP, API and others

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about JSON to Go Struct Converter and anybody who knows can answer. No account needed.

Common uses

  • JSON to Go StructPaste an API response and get a Go struct with json tags to unmarshal it

Same job, other tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)