JSON to Go Struct

Generate Go struct declarations from a representative JSON object or array, including nested types, exported field names, and original-property json tags.

Choose the package and root type names, then generate a complete Go source file with valid exported fields and original-property json tags. Review sample-dependent choices before using the types in an application.

How JSON values map to Go types

How to generate Go structs from JSON

  1. Paste a JSON object or non-empty array, or load the sample data.
  2. Choose the package and root type names, and whether json tags should include omitempty.
  3. Generate the Go source, review the inferred types, then copy or download the result.

JSON to Go struct FAQ

What JSON input can I use?

Use one JSON object or any non-empty JSON array. A top-level array becomes a named slice, and every object item in an array contributes to the inferred fields. Property names must be representable by Go's standard encoding/json struct tags; unsupported names produce an error instead of being silently changed.

How are object arrays and missing fields handled?

Object arrays are merged across all supplied items. A field seen in only some items is still generated from the values that are present. The omitempty option changes every json tag; it does not add pointers or validate required fields.

What happens to null and mixed values?

A null value, an incompatible mixture of value types, or an array containing incompatible values becomes any. An empty array becomes []any because the sample does not reveal its element type.

Can I use the generated types without reviewing them?

Treat the result as a sample-based starting point. Check optional fields, time strings, map-like objects, numeric ranges, and identifiers that may exceed the exact range of a JSON number before adding the types to your project.

Is my JSON uploaded?

No. The JSON is parsed and converted in this browser tab by this tool. It is not uploaded to a server.

Related tools: JSON Formatter · JSON to TypeScript · JSON Schema Generator

Code Formatters

Code Formatter and Code Beautifier tools for Python, JSON and other languages.

More tools

JSON & Data Tools

Compare JSON, validate schemas, and convert JSON to CSV or YAML.

More tools

Spreadsheet Tools

View CSV and Excel files, format tables, or convert CSV to Excel and SQL.

Markdown Tools

Write in Markdown Editor and convert Markdown to HTML or plain text.

Text Tools

Compare text, count words, sort lines, and find or replace text.

Audio Conversion & Playback

Convert audio, play sound or PCM files, and edit audio metadata.

Audio Editing & Effects

Edit, join or split audio, remove noise, and adjust speed, pitch or volume.

More tools

Speech Tools

Generate AI speech from text, transcribe recordings, or record your voice.

Video Tools

Convert and compress video, trim clips, or resize frames.

More tools

Video Playback & Recording

Play video, record your screen or camera, or use Online Mirror.

PDF Tools

Merge PDF, split pages, compress files, and convert PDF to images.

More tools

Image Tools

Convert images, resize photos, compress files, and extract text with OCR.

More tools

Image Creation

Create GIFs, text images, screenshots, word clouds and favicons.

Subtitle Tools

Edit subtitles, convert SRT to VTT, and adjust subtitle timestamps.

Archive Tools

Extract archives, create ZIP files, and compress folders.

Encoders | Decoders

Encode or decode Base64, escape URLs, and work with HTML or Unicode escapes.

More tools

Number Tools

Convert number bases, turn numbers into words, and work with binary or hex.

Calculators

Use percentage, fraction and statistics calculators for everyday calculations.

Time Tools

Check Online Clock, use Stopwatch, or calculate date differences.

Network Tools

Find your IP address, test IPv6, and calculate CIDR ranges.

Unit Conversions

Convert units of length, weight, temperature and data storage.

Color Tools

Convert colors, pick a palette from an image, and check color contrast.

QR Codes & Barcodes

Create or read QR codes and barcodes, including Wi-Fi QR codes.

Developer & Security Tools

Generate hashes, passwords and UUIDs, test regular expressions, and work with code utilities.

More tools

Utility Tools

Check screen size, measure with a screen ruler, test your keyboard, or use a teleprompter.

Games

Take a break with Smash Golden Eggs.