---
title: "JSON to Go Struct Generator | JSON Lark"
description: "Generate Go structs with json tags from JSON samples: omitempty for optional keys, pointers for nulls, optional time.Time. Runs in your browser."
url: https://jsonlark.me/json-to-go/
---

Sheet 02 Go structs

# JSON to Go

Paste JSON samples and get Go structs with encoding/json tags, gofmt-aligned and ready to paste into a package.

## How it works

Each sample is read as a value of the root type; keys missing from some objects are optional, and values that are sometimes `null` are nullable. Field names follow Go conventions, initialisms included (`userId` becomes `UserID`), and every field keeps its JSON key in a tag.

- **omitempty and omitzero**: Optional keys get `omitempty`. Optional structs and `time.Time` values get `omitzero` (Go 1.24), because `omitempty` never omits a struct.
- **Pointers**: Nullable values become `*string` and the like, so null and the zero value stay different. Slices, maps and `any` are never pointers: they can already be nil.
- **time.Time**: Only strings in RFC 3339 form with a time zone, which is what `time.Time` can decode.
- **Mixed types**: Values that are sometimes a number and sometimes a string become `any`, with a comment listing what was seen.

**Want a real response to try?** [WebTraceCheck's free IP API](https://webtracecheck.com/ip-api) answers in plain text or JSON, so you can paste its JSON here for a quick struct, or call it from the Go code that uses one.

## Questions

**Why is a key skipped with a comment?**

Go's encoding/json can only name keys made of letters, digits and a few punctuation marks in a struct tag. A key containing a comma, quote, backslash or a line break cannot be mapped, so it is listed in a comment instead of producing a field that would never fill.

**Why int64 rather than int?**

JSON numbers have no size, so int64 is the safe choice on every platform. Integers larger than int64 become uint64 when they are positive, or float64 with a comment.

**Is my JSON uploaded?**

No. The code is generated by JavaScript running in this tab, and nothing you paste leaves it. The site counts page views with Cloudflare Web Analytics, which sets no cookies and never receives what you paste.
