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
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste a YAML document into the input panel.
Set the root struct name and package name.
Toggle json tags and pointer types for nested structs.
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.
name: Alice
active: truepackage 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.
Related Tools
JSON to Go Struct Converter
Generate Go structs from a JSON example. Infers types, creates nested structs, handles arrays as slices, and emits json:"..." struct tags ready for encoding/json.
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML — for config files, CI pipelines, and Kubernetes manifests.
YAML to TypeScript Converter
Generate TypeScript interfaces from a YAML example. Parses YAML to JSON internally, then emits typed interfaces with nested types and array element inference.
YAML to Python Converter
Generate Python classes from a YAML example. Pick @dataclass, pydantic, TypedDict, or attrs style. Targets Python 3.10+ or 3.9 type syntax.
YAML Validator
Validate YAML syntax online. Shows valid/invalid status with exact error line and column, plus structure stats for valid documents.
YAML Beautifier
Format and prettify YAML with configurable indentation and optional key sorting. Validates YAML syntax instantly.

