SnappTools logoSnappTools

JSON to Go Struct

Paste JSON and generate Go struct definitions with json tags. Handles nested objects and arrays.

JSON Input
Go Struct Output

About JSON to Go Struct

JSON to Go Struct converts JSON data into Go struct definitions with proper json tags. It infers field types from the JSON values, handles nested objects with separate struct definitions, and generates idiomatic Go code with exported field names and json struct tags.

Go developers frequently work with JSON APIs and need to define struct types to unmarshal responses. Writing these by hand from large API responses is tedious. This tool generates the complete struct definitions automatically.

The output follows Go naming conventions (camelCase JSON keys to PascalCase field names) and uses appropriate Go types (string, int, float64, bool, []T, struct).

Features

  • Generates Go structs from JSON sample data
  • Proper json struct tags
  • Nested object support with separate struct types
  • Arrays become Go slice types
  • Exports field names (PascalCase)

Common Use Cases

  • Generating Go types from REST API response examples
  • Bootstrapping Go struct definitions from JSON specs
  • Creating Go types for JSON config file unmarshaling
  • Saving time on repetitive struct definition work