YAML to JSON Converter

Turn YAML into JSON. Comments are dropped. Anchors are resolved.

Read a YAML config as JSON

APIs and many scripts want JSON. People keep writing YAML because the indentation is readable. This page parses YAML 1.2, resolves anchors and aliases, and prints JSON. Comments are documentation for humans; they are not data, so they do not appear in the output.

How to use it

  1. Paste one YAML document. A multi-document stream separated by --- is not a single JSON value; split it first.
  2. Indentation is significant. Tabs usually fail. Use spaces, and keep nested keys aligned.
  3. Pretty print is for reading. Turn it off if you are pasting into a one-line log.
  4. yes, on and no stay strings. Only true, false and null become JSON booleans and null. That is YAML 1.2, not the older 1.1 rules some blogs still describe.
  5. To go back, use JSON to YAML.

Questions

The error mentions indentation.

A child key must be indented further than its parent, and the indent must be consistent. A line that starts with a tab while the rest uses spaces will fail even if it looks aligned.

My list became a string.

List items need - followed by a space, at the right indent. -item without a space is a string.