CODDY Tool

JSON to Go

Turn a JSON sample into Go type definitions.

Paste a JSON response and get Go types back. Every element of an array is merged, so fields missing from some objects come out optional rather than required.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

This is one of the thingsJSON Type Generatordoes — open it for everything else it supports.

Loading tool…

What JSON Type Generator supports

  • TypeScriptExported interfaces.
  • GoStructs with json tags.
  • KotlinData classes.
  • SwiftCodable structs.
  • PythonDataclasses.
  • C#Classes with properties.

About JSON to Go

Go structs need two things a naive generator skips: a json tag on every field whose name differs from the key, and a way to distinguish an absent value from a zero one.

Field names are exported and pascal-cased, which almost always differs from the JSON key, so every field gets a tag. Optional fields also get omitempty, so marshalling back out does not invent keys the API never sent.

Optional and nullable fields are emitted as pointers. That is how Go tells absent from zero, and it matters far more than it first appears: without a pointer, a missing integer and an integer that is genuinely 0 are indistinguishable once unmarshalled.

How to generate Go types

  1. Paste your JSON

    A whole array is better than one object — more samples means a more accurate type.

  2. Name the root type

    Nested objects are named automatically from the keys that hold them.

  3. Copy the definitions

    Types are emitted children first, so the file compiles in order.

Frequently asked questions

Why is a field optional when my sample has it?

Because at least one object in the array you pasted was missing it. That is a real difference in the data, and a type that marks it required would compile and then fail at runtime on the object that lacks it.

Why did a field come out as unknown?

Because the same key held genuinely different types across your samples — a number in one object and a string in another. There is no single type that describes both, so widening to unknown is the honest answer.

Does it handle nested objects?

Yes. Each nested object becomes its own named interface, named after the key holding it, and a key holding an array is singularised — users produces a User rather than a Users.

Is my JSON uploaded anywhere?

No. Everything is parsed and generated in this browser tab, which matters when the sample is a response from an unreleased API.

All Developer Tools

JSON to Go is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.