{ } Schemato

JSON to Go struct Converter

Paste a JSON sample, get production-ready Go struct code. Runs entirely in your browser.

Examples:

Typical user object from a /me API response

InputJSON
OutputGo struct

About this converter

Go developers consuming HTTP APIs almost always start by sketching out a struct that matches the response. This converter does that step for you, including correct json tags, omitempty for optional fields, and pointer types where the field can be missing.

Why convert JSON to Go struct

  • Decode JSON straight into typed Go structs with json tags.
  • Avoid map[string]interface{} chaos in handlers and pipelines.
  • Make data shapes part of your codebase and your code review.

How to use

  1. Paste your JSON on the left panel, or pick one of the sample tabs above.
  2. The converter infers field names, optionality, and types automatically.
  3. Copy the generated Go struct on the right and drop it straight into your codebase.

Common pitfalls

  • Go's zero values mean the difference between 'absent' and 'present-but-zero' is invisible. Use pointer types (already done for optional fields here) only where you actually need to distinguish.
  • If a JSON number can be very large, you may need `int64` instead of `int` — adjust manually based on your domain.
  • JSON keys with dashes or special characters are exposed via the json tag, but the Go field name is PascalCase — review case sensitivity if you re-marshal.

FAQ

Is this json to go struct converter free?
Yes. It is fully free, no signup, and runs entirely in your browser. We do not store your input.
Does it work with nested objects and arrays?
Yes. Nested objects produce separate named types, and arrays infer the element type from the first non-null sample.
What about optional / nullable fields?
Fields whose value is null in the sample (or marked optional in JSON Schema / Prisma / GraphQL) are marked optional/nullable in the output. For real APIs, you may want to widen optionality manually after generation.
Can I generate Go Struct from multiple JSON samples?
Today the tool processes a single sample. For more aggressive inference across multiple shapes, run the converter on the union/merge of your samples or open an issue.
Is the source code available?
Yes — the entire project is open source. See the GitHub link in the footer.

Related converters