JSON to Go Struct Generator

Generate Go struct definitions from JSON with json tags, nested structs, slices, and proper Go naming conventions.

What is JSON to Go Struct Generator?

This tool converts JSON data into Go struct definitions with proper json tags. It automatically infers types, converts field names to PascalCase (Go convention), handles nested structs, slices, and generates ready-to-use Go code.

How to Use

  1. Set the root struct name and configure options (pointers, date detection, omitempty)
  2. Paste your JSON data into the input area
  3. Click "Generate Go Structs" and copy the output into your Go project

Why Use This Tool?

Automatically infer Go types from JSON values
Convert field names to PascalCase following Go conventions
Generate nested structs with correct ordering (children first)
Support json tags with optional omitempty for optional fields
Detect ISO-8601 date strings and map them to time.Time

Tips & Best Practices

  • Use realistic sample data — type inference depends on actual values
  • Enable pointers for nested structs to handle optional/nullable objects
  • omitempty tags allow fields to be omitted when empty in JSON output
  • Null values in JSON are converted to pointer types or interface{}

Frequently Asked Questions

How are JSON types mapped to Go?

JSON strings → string, integers → int, floats → float64, booleans → bool, null → interface{} or pointer, arrays → []T, objects → separate nested structs. ISO-8601 date strings can be detected as time.Time when the option is enabled.

Why use PascalCase for field names?

Go convention requires exported struct fields to start with an uppercase letter. This tool automatically converts camelCase, snake_case, or kebab-case field names to PascalCase while preserving the original JSON key in the json tag.

What does the "Use pointers" option do?

When enabled, nested struct fields are generated as pointers (*StructName) instead of values. This is useful for optional nested objects and allows proper JSON unmarshaling of null values.

What is omitempty?

The omitempty tag option tells Go's JSON encoder to omit the field when encoding if the field has an empty value (zero value, nil, empty string, etc.). This is useful for optional fields in API responses.

Is my data sent to a server?

No, all processing happens entirely in your browser. Your JSON data never leaves your device.

Related Tools