YAML to/from JSON
Convert YAML to JSON and JSON to YAML, with the line and column of any parse error and a warning when a value can't survive the round trip, such as comments, anchors, custom tags or dates. Runs in your browser.
Last updated
What it does
- Converts YAML, such as Kubernetes manifests, Docker Compose files and CI pipelines, to JSON, and JSON back to YAML.
- Reports parse errors with the line and column, including duplicate keys and bad indentation, which YAML is quick to punish.
- Expands anchors, aliases and
<<merge keys into plain values, and returns several documents separated by---as a JSON array. - Warns about anything that doesn't survive the trip: comments, anchors, custom tags such as
!Ref,.infand.nan, and integers too large for JSON tools that use doubles.
The Norway problem
Older YAML 1.1 parsers, still used by many tools, read unquoted yes, no, on, off, NO and y as booleans, numbers with a leading zero such as 0755 as octal, and 10:30 as a base-60 number. A country code NO silently becomes false.
This converter follows YAML 1.2, where those stay strings, and when it writes YAML it quotes them so every parser reads them back unchanged.
Questions
- Why did my comments disappear?
- JSON has no comments, so they are dropped when converting to JSON, and there are none to bring back when converting to YAML. The warning box says when this happens.
- What happens to !Ref and other custom tags?
- Tags such as CloudFormation's
!Refor!GetAttare dropped and only the value after them is kept. Convert those templates with the tool that defines the tags. - Is my file uploaded?
- No. Parsing and conversion run in your browser.