BRev Free Tools
At BRev Digital, essentials should be a right — free, forever.
Open in workspacekeep several tools open at once
All tools
JSON to types

JSON to Go struct

encoding/json only marshals exported fields, so every snake_case or camelCase JSON key becomes an exported PascalCase field carrying a `json:"original_name"` struct tag. Paste a payload and the tags, nesting and slice types are written for you — no hand-transcribing forty field names.

Nullability matters more in Go than most targets: a field that can be null becomes a pointer (*string), because a plain string cannot distinguish "" from absent. Merge two or three real responses as separate samples and fields that sometimes vanish are typed accordingly instead of panicking at Unmarshal time.

Watch omitempty before you copy it everywhere: it drops every zero value on Marshal, so an intentional 0, false or empty string silently disappears from your output JSON too.

Inputpaste JSON samples or a schema — multiple samples merge into one type
Loading the type generator…
Generated typesregenerates as you type
Loading the type generator…

How JSON type inference works

The generator reads your JSON and builds the strictest type that fits every value it saw: objects become interfaces, structs or classes; arrays become typed lists; a value that appears as both a number and a string becomes a union. Repeated string values (like "active" / "inactive") can be promoted to an enum, and ISO 8601 timestamps or UUIDs can map to your language's date and UUID types — both are toggles above.

Why add multiple samples?

One API response rarely shows every field — optional fields are missing, nullable fields happen to be set. Add two or three real responses with Add sample and they merge into a single type: a field present in every sample stays required, and a field that only some samples carry becomes optional. More samples always produce a more honest type.

Nullable is not optional

A field that appears as null in a sample is nullable — it is always present, but its value may be null (string | null). A field that is missing from some samples is optional — it may not exist at all (field?: string). Serializers treat the two very differently, which is why the generator keeps them distinct instead of collapsing both to "maybe".

JSON Schema in, types out

Already have a JSON Schema? Switch the input to JSON Schema and the types are derived from the schema's declared properties, required list and formats instead of being inferred from samples — or pick the JSON Schema output target to go the other way and generate a schema from samples.

Generated on your device with the quicktype engine — nothing is uploaded.

FAQ

Does my JSON leave the browser?

No — generation runs entirely on your device with the quicktype engine. API responses containing live tokens or customer data never leave the page.

Why are some fields pointers?

A *string can be nil, which is the only faithful way to represent a JSON field that may be null or absent. A plain string would silently read as "" and you could no longer tell "empty" from "missing".

Why did my lowercase field stop round-tripping?

encoding/json ignores unexported (lowercase) struct fields entirely. Every generated field is exported PascalCase with a json tag pointing back at the original key — keep that shape when you edit.

Can it detect time.Time?

Yes — with "Infer dates & UUIDs" on, ISO 8601 timestamp strings are typed so they parse into time values rather than staying raw strings.