ops@toolbox:~$ yamljsonconverter --run

YAML ↔ JSON Converter

Convert YAML to JSON and back, with validation, built for Kubernetes and Ansible files.

Two serializations of the same data

YAML and JSON describe the same structures (maps, lists, scalars) with different trade-offs. YAML won the configuration wars (Kubernetes, Ansible, docker-compose, CI pipelines) because it allows comments and reads cleanly; JSON won the API wars because it's unambiguous and universally parseable. Converting between them is a daily task: turning a Kubernetes manifest into JSON to feed jq or an API call, or turning an API response into YAML to drop into a values file. In fact, every JSON document is already valid YAML (YAML is a superset) so the interesting direction is YAML→JSON.

Conversion gotchas

Three things to watch. Comments are lost going to JSON: JSON has nowhere to put them. The Norway problem: in older YAML 1.1 parsers, unquoted no, yes, on and off parse as booleans, so a country code NO becomes false; this converter uses a modern parser, but the files you write will be read by other parsers, so quote ambiguous strings anyway. Same for version numbers: version: 1.20 is the float 1.2, quote it. Anchors and aliases (&ref/*ref) are expanded during conversion; the deduplication is gone in the output.

Why indentation errors dominate

YAML's structure is its whitespace, and tabs are forbidden for indentation. The error position this tool reports usually points at or just after the real problem, a two-space list under a four-space key, or an invisible tab pasted from a terminal. When a manifest fails mysteriously, round-tripping it through JSON and back is also a quick way to normalise the formatting.

Related tools

Base64 Encoder / Decoder
Encode and decode Base64 and URL-safe Base64, with full UTF-8 support.
Hex Converter
Convert between text, hexadecimal, decimal and binary, plus number base conversion.
JSON Formatter & Validator
Pretty-print, minify and validate JSON with precise error locations.
URL Encoder / Decoder & Parser
Percent-encode or decode text, and split any URL into its parts.