JSON Parser

JSON to Go Struct Converter Online

Paste any JSON and get ready-to-use Go types in one click. Nested objects, arrays, optional fields and awkward key names are handled for you, and everything runs in your browser, so API responses and sample payloads are never uploaded.

How to convert JSON to Go

  1. Paste your JSON, or click Upload to load a file. Use a sample that includes every field, since the types are inferred from it.
  2. Set the Root class name if you want something other than Root.
  3. Review the output on the right and click Copy.

Example

JSON input

{
  "id": 1,
  "name": "Alice",
  "active": true,
  "score": 98.5,
  "tags": ["admin"],
  "address": { "city": "New York" }
}

Go output

package main

type Root struct {
	ID      int64    `json:"id"`
	Name    string   `json:"name"`
	Active  bool     `json:"active"`
	Score   float64  `json:"score"`
	Tags    []string `json:"tags"`
	Address Address  `json:"address"`
}

type Address struct {
	City string `json:"city"`
}

JSON to Go type mapping

JSONGo
stringstring
whole numberint64
decimal numberfloat64
booleanbool
array[]T
objecta struct
null / unknowninterface{}

Naming and structure

Fields are exported (PascalCase) and follow Go initialism rules, so id becomes ID and url becomes URL. Every field carries a json tag with the exact original key.

  • A field that is missing from some array items, or null in the sample, becomes a pointer with the omitempty tag, so you can tell "absent" from the zero value.
  • The output starts with package main; change it to your package name.
  • When an array contains objects, their fields are merged: a field missing from some items is treated as optional, and a field that is a whole number in one item and a decimal in another becomes a decimal.
  • The top-level JSON can be an object or an array of objects.

Using the generated types

var root Root
if err := json.Unmarshal([]byte(data), &root); err != nil {
    log.Fatal(err)
}

Related tools

Describe the same data with the JSON Schema generator, get TypeScript interfaces, create a SQL table, fix broken input with JSON Repair, or compare payloads with JSON Diff.

Frequently asked questions

How do I convert JSON to a Go struct?
Paste your JSON and copy the result. Each nested object becomes a named struct, arrays become slices ([]T), integers become int64 and decimals become float64. Field names are exported and follow Go initialism rules, so id becomes ID and url becomes URL.
What do pointers and omitempty mean in the output?
A field that is missing from some objects in an array, or null in the sample, is generated as a pointer type with the `omitempty` tag, so you can tell "absent" from the zero value when unmarshalling with encoding/json.
Will it work with encoding/json?
Yes. Every field carries a `json:"key"` tag that matches the original key exactly, so json.Unmarshal and json.Marshal round-trip your data. Everything runs in your browser — your JSON is never uploaded to a server.
Handles JSON files up to 20MB smoothly