WebToolsPlanet
Converter Tools

YAML to Go Struct Converter

Paste a YAML document and get Go structs with proper field names, types, and `json:"..."` tags — ready for `encoding/json` or `yaml.v3`.

Last updated: May 27, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is YAML to Go Struct Converter?

Go projects that consume YAML (Kubernetes operators, Helm-related tools, CI runners) typically declare structs with json or yaml tags and decode the YAML into them. Writing the structs by hand for a large YAML schema is tedious — each field needs an exported name, a Go type, and a tag.

This tool parses YAML to JSON internally, then reuses the JSON-to-Go generator. The output uses `json:"..."` tags by default; if you need YAML-specific tags, replace `json` with `yaml` after generation (both gopkg.in/yaml.v3 and sigs.k8s.io/yaml accept JSON tags, but explicit yaml tags are clearer).

How to Use YAML to Go Struct Converter

1

Paste a YAML document into the input panel.

2

Set the root struct name and package name.

3

Toggle json tags and pointer types for nested structs.

4

Copy the generated structs into your project.

Common Use Cases

  • Bootstrapping Go structs from a Kubernetes manifest or CRD example.
  • Generating types for a Go service consuming YAML config.
  • Producing model structs for a CI/CD tool.
  • Converting a YAML schema example to typed Go structs.

Example Input and Output

A YAML mapping becomes a Go struct with json tags.

YAML input
name: Alice
active: true
Generated Go struct
package main

type Root struct {
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

Privacy

All YAML parsing and Go generation happen in your browser. No content is sent to a server.

YAML coverage

The internal YAML parser handles the common subset (mappings, sequences, scalars). Anchors, aliases, and explicit tags may not be supported.

Frequently Asked Questions

Why json tags and not yaml tags?
Both gopkg.in/yaml.v3 and sigs.k8s.io/yaml read JSON tags. For YAML-specific naming, change "json" to "yaml" in the output — the rest of the tag content is the same.
When should I use pointer types for nested structs?
Pointers let nested structs be nil/missing without a zero-value placeholder. Enable for sparse YAML where many nested mappings are optional.
Does this send my YAML anywhere?
No. All parsing happens locally in your browser.