Nifty / Tools / Code from JSON

JSON to Go

Paste a JSON sample and get Go structs for it, including nested types and arrays.

json-to-go
JSON sampleDrop a file here
Go
Loading…

Runs in your browser. Nothing you paste is uploaded or stored.

How to use the JSON to Go

  1. Paste a JSON sample on the left. Several examples in an array give better types.
  2. Name the top-level type.
  3. Copy the Go code.

Questions

Is my data uploaded anywhere?

No. The tool runs entirely in your browser. Nothing you paste or drop is sent to a server, logged or stored, so it's safe for API responses, config files and other private data.

How are optional fields detected?

If you paste an array of objects and a field is missing from some of them, it's marked optional. More sample data gives more accurate types.

Can I do this in VS Code?

Yes. Nifty Paste JSON as Code pastes JSON straight into a Go file as structs.

Related tools