JSON to Go Converter

Generate Go structs with JSON tags from a sample response.

Runs in your browser Free · no accountFile upload supported

JSON

Go

This conversion happens locally in your browser. Your files are never uploaded.

About the JSON to Go converter

Writing Go structs to match an API response is mechanical work that is easy to get subtly wrong — a mistyped tag means a field silently stays at its zero value with no error anywhere.

Paste a real response and get structs with the tags already correct, nested types named, and field names exported the way Go expects.

Naming follows Go conventions

Fields are exported, because `encoding/json` cannot populate an unexported one. `user_name` and `userName` both become `UserName`, with the original key preserved in the tag so unmarshalling still matches.

Common initialisms are capitalised the way the Go style guide asks: `id` becomes `ID`, `url` becomes `URL`, `api` becomes `API`. This is exactly the thing linters complain about when it is done by hand.

Types chosen

Whole numbers become `int` and fractional ones `float64`. If a field is an integer in your sample but could be fractional in general, widen it yourself — JSON has only one number type and cannot tell you.

A field seen only as null becomes `*string` with `omitempty`, since a pointer is how Go distinguishes absent from zero.

Types come from one sample

Everything here is inferred from the JSON you paste. A field that happens to be absent from your example will be absent from the output, and a field that is null in the sample cannot be typed at all — only marked as nullable.

Paste the richest response you have, then review the optional and nullable fields by hand. Treat the result as a fast first draft rather than a schema.

Frequently asked questions

Why pointers for some fields?

Go cannot otherwise tell an absent field from one set to its zero value. A pointer distinguishes missing from empty, which matters for booleans and numbers especially.

Why is my null field typed so loosely?

Because a single null tells you nothing about what the field looks like when it is populated. It is marked nullable or optional so the code compiles, and it is the first thing worth correcting by hand.

Is my JSON uploaded?

No. The conversion runs in your browser, which matters when the sample you are pasting is a real API response with real customer data in it.