YAML to JSON

Convert YAML to JSON or JSON back to YAML, with the awkward parts handled rather than ignored. Anchors and aliases resolve, multi-document streams parse into an array, and — unusually — merge keys are actually expanded. That last one matters more than it sounds: most converters leave `<<` sitting in the output as a literal property, so a GitLab CI file or a docker-compose config comes out with the wrong shape and you only find out when something downstream breaks. Here the merged mapping is folded in properly, with explicit keys taking precedence exactly as the specification says. Errors point at the line that caused them, tabs get called out specifically because YAML forbids them for indentation and the error it produces otherwise is famously unhelpful, and you are told plainly that comments cannot survive the trip. Everything runs in your browser.

YAML features and how they convert

FeatureResult in JSON
&anchor / *aliasExpanded to the referenced value
<< merge keyFolded in; explicit keys win
--- multi-documentAn array, one entry per document
# commentsLost — not part of the data
| and > block scalarsA single string, folded as written
Tabs for indentationA parse error — YAML forbids them
'7' versus 7String versus number, preserved

When to use it

  1. Turn a CI or Kubernetes config into JSON to inspect its real structure.
  2. Convert JSON API output into YAML for a config file.
  3. Check what a file with anchors and merge keys actually resolves to.
  4. Find the line causing a YAML parse error.
  5. Flatten a multi-document YAML stream into a JSON array.

How to Use

  1. Paste your YAML, or switch direction and paste JSON.
  2. Turn on multi-document if your file has several separated by ---.
  3. Read the converted output, or the error with its line number.
  4. Copy or download the result.

Features

  1. Merge keys expanded, not left as a literal '<<'
  2. Anchors and aliases resolved
  3. Multi-document streams into a JSON array
  4. Both directions, with indent and pretty-print control
  5. Errors pinned to a line number
  6. Tabs and comment loss called out explicitly
  7. 100% client-side — config files stay private

FAQs

What is a merge key, and why does it matter here?

`<<` folds another mapping's keys into the current one — it is how docker-compose, GitLab CI and Kubernetes manifests share common blocks. Most converters, including js-yaml on its own, leave `<<` as a literal property, so the JSON has a nested `"<<"` key instead of the merged fields. This tool expands it properly, with explicit keys beating merged ones as the spec requires.

Why did my tabs cause an error?

YAML does not allow tabs for indentation — only spaces. The parser error for it is unhelpfully indirect, so it is called out explicitly here. Replace the tabs with spaces and it will parse.

What happens to my comments?

They are lost. Comments are not part of the data model, so they cannot be represented in JSON and have nothing to round-trip back from. You are warned when your input contains them, rather than finding out afterwards.

Does it handle multi-document files?

Yes — turn on the multi-document option and each document separated by `---` becomes an entry in a JSON array. Without it, a stream containing more than one document is reported as an error rather than silently giving you only the first.

Will the round trip give me back exactly what I started with?

The data will match, but the formatting will not. Comments are gone, anchors are expanded into their values, quoting style may change, and key order is preserved but block versus flow style is not. Use it to convert, not to reformat a file in place.

Is my YAML uploaded?

No. Parsing happens in your browser. Config files routinely contain hostnames, internal service names and occasionally secrets — none of it is sent to a server, logged, or stored.

Technical Details

Parsing uses js-yaml, which is one of the few dependencies genuinely worth taking: YAML has anchors, aliases, multi-document streams, block scalars, implicit typing and tags, and a hand-rolled parser gets those wrong in ways that corrupt data quietly rather than failing loudly. One thing js-yaml does not do is expand the merge key. An alias resolves, but `<<` arrives as a literal property rather than having its contents folded into the surrounding map — which is wrong for a converter, because merge keys are everywhere in the configuration people actually paste: GitLab CI, docker-compose and Kubernetes manifests all lean on them heavily, and leaving `<<` in the output silently changes the shape of the data. They are therefore expanded here per the specification: the value may be a single mapping or a sequence of them, earlier entries in a sequence take precedence over later ones, and any key written explicitly in the map beats anything merged in. A WeakSet guards against the self-references aliases make possible. Errors are unwrapped from js-yaml's exception so the offending line number can be shown, tabs are called out specifically because YAML forbids them for indentation and the resulting error is famously unhelpful, and comment loss is flagged since comments are not data and cannot survive.

Data & CSV Tools

Data & CSV Tools

  • CSV Graph Plotter
  • YAML Formatter & Validator
  • XML to JSON
  • Query String to JSON
  • Config to JSON
  • CSV Manipulator
  • Table Format Converter
  • CSV Cleaner