{ }jsonkit
Tools/Convert/JSON to Go
Search tools…⌘K
Format
{ }JSON Formatter
≡→JSON Minifier
\"JSON Escape / Unescape
a→zJSON Sorter
⇄{}JSON Flattener
Validate
JSON Validator
±JSON Diff / Compare
§JSON Schema Generator
JWT Decoder
ΔJSON Patch / Merge Patch
kbJSON Size Analyzer
Convert
→csvJSON to CSV
csv→CSV to JSON
⇄ymlJSON ⇄ YAML
⇄xmlJSON ⇄ XML
→tsJSON to TypeScript
b64Base64 Encode / Decode
%2FURL Encode / Decode
clkTimestamp Converter
→zJSON to Zod
→pyJSON to Pydantic
→goJSON to Go
→javaJSON to Java
⇄jsonlJSON ⇄ JSONL
5→JSON5 / JSONC to JSON
Query
$.JSONPath / JQ Tester
.*Regex Tester
Generate
Mock JSON Data Generator
idUUID / NanoID Generator
#Hash Generator
→go

JSON to Go Structs

Typed structs with json tags and optional detection.
processes as you type · client-side
Sample
Upload
Optional detection
Inline nested structs
⧉ Copy output ⌘C
Download
Share
Clear
Input219 B · paste or drop a file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Structs
1 2 3 4 5 6 7 8 9 10 11 12 13 14
type Plan struct { Tier string `json:"tier"` Seats int64 `json:"seats"` Renews string `json:"renews"` } type AutoGenerated struct { Id string `json:"id"` Name string `json:"name"` Email string `json:"email"` Active bool `json:"active"` Roles []string `json:"roles"` Plan Plan `json:"plan"` }
✓ valid (RFC 8259)219 B → 329 B0.0 msLn 1, Col 1UTF-8

About JSON to Go

The JSON to Go converter turns a sample JSON payload into ready-to-use Go structs, complete with `json:"..."` struct tags that preserve your original field names. Paste an API response and get exported PascalCase fields, correctly inferred Go types and named structs for every nested object — the exact boilerplate you would otherwise hand-write before unmarshalling.

It runs entirely in your browser. Nothing you paste is uploaded, logged or sent to a server — the struct generation happens in JavaScript on your own machine, so it is safe for production payloads, internal API shapes and customer data. Turn off your network and it still works.

It is built for Go developers wiring up `encoding/json`: model a third-party webhook, scaffold a config type, or bootstrap a client for an undocumented endpoint. Whole numbers become `int64`, decimals `float64`, arrays become slices, and null or empty values fall back to `interface{}`. Free forever, no signup, no file-size gate.

How it works

Types inferred from the values

Strings map to `string`, booleans to `bool`, whole numbers to `int64` and decimals to `float64`. Arrays become slices (`[]string`, `[]Item`), and any null value or empty array element becomes `interface{}` so the struct still round-trips. Field names are PascalCased for export while the json tag keeps the exact original key.

Named structs for nested objects

Every nested object becomes its own named, reusable struct — a `plan` object turns into a `Plan` struct referenced from the parent. Objects inside arrays are merged into a single element struct, so `[]User` describes all the elements at once. Names are de-duplicated with a numeric suffix when two paths would collide.

Optional detection across arrays

With Optional detection on (the default), the generator compares every object in an array. Any key that is missing from some elements is marked optional: the tag gains `,omitempty` and the field type becomes a pointer (`*string`) so it can be nil. This mirrors how real Go code distinguishes an absent field from a zero value.

Inline nested structs toggle

Leave Inline off for named top-level structs (easier to reuse and reference across your package). Flip it on to embed each nested object as an anonymous `struct { ... }` literal directly inside its parent, matching a single self-contained type. Either way, the name, type and tag columns are aligned with tabs exactly like gofmt output.

Frequently asked questions

Is it safe to paste production JSON here?

Yes. All struct generation happens locally in your browser with JavaScript — the JSON is never uploaded or sent anywhere. You can disconnect from the internet and the tool keeps working.

Why does it use int64 instead of int?

Whole numbers map to int64 because JSON numbers can exceed the range of a 32-bit int and Go's json package decodes into int64-compatible sizes safely. Change the type to int, int32 or uint in your editor if your domain guarantees a smaller range.

What does the omitempty and pointer output mean?

When Optional detection is on and a field is missing from some objects in an array, the generator adds ,omitempty to the json tag and makes the field a pointer (like *string). That lets your code tell an absent field apart from a zero value, and omits it when marshalling back to JSON.

Why did a field become interface{}?

A value that is null, an empty array, or a mix of incompatible types can't be pinned to one concrete Go type, so it falls back to interface{} (equivalent to `any`). Provide a fuller sample with real values and the generator will infer a precise type.

Should I use named or inline nested structs?

Use named structs (Inline off) when you want to reference or reuse the nested types elsewhere in your package — it's the more common Go style. Use inline structs when you want one self-contained type definition with everything nested in place.