Skip to content
Logo Any Help Me

YAML ↔ JSON Converter: Convert Online

YAML
JSON
Ready

The Same Data, Two Very Different Formats

YAML and JSON describe the same data model, maps, sequences, scalars, so converting between them is mostly mechanical. What differs is who they were designed for. JSON is unambiguous and easy for machines; YAML drops the punctuation and uses indentation instead, which makes it pleasant to hand-edit and gives it a set of failure modes JSON does not have.

This converter runs both directions with configurable indentation, and reports parse errors with the line they occurred on.

How to Convert

Each direction has its own button, so you convert deliberately rather than on every keystroke.

  1. Paste YAML into the left pane or JSON into the right.
  2. Set the indentation. Two spaces is the usual YAML convention; you can also choose tabs for the JSON side.
  3. Convert in the direction you need. The result appears in the opposite pane.
  4. Read the status line, which reports success or the parse error and its location.
  5. Copy either pane independently, each has its own copy control.
  6. Note that YAML tabs are a parse error in the YAML direction; the format forbids them for indentation.

Where the Conversion Loses Something

JSON to YAML is essentially lossless, since every JSON construct has a YAML equivalent. The other direction is not. YAML comments vanish, because JSON has nowhere to put them, and in a configuration file the comments are often the most valuable part. Anchors and aliases, which let YAML reference a block defined elsewhere, are expanded into duplicated content. Multiple documents in one stream, separated by `---`, cannot be represented in a single JSON value.

YAML also has scalar types JSON lacks: dates, explicit tags, and the notorious implicit conversions. A value written as `yes`, `on` or `off` becomes a boolean in YAML 1.1 parsers, and an unquoted `1.0` is a float rather than the string you may have meant. Version numbers and country codes are the usual casualties.

Constructs That Do Not Survive the Round Trip

What happens to each YAML feature when it becomes JSON.

YAML featureIn JSONResult
# commentNo equivalentDiscarded
&anchor / *aliasNo equivalentExpanded to duplicates
--- multiple documentsOne value onlyOnly the first survives
Multi-line block scalarsString with \nPreserved, formatting flattened
Unquoted datesNo date typeBecomes a string
yes / no / on / offtrue / falseConverted to booleans

The comment row is the one that matters in practice. Converting a documented configuration file to JSON and back leaves you with working configuration that no longer explains itself, which is why the round trip is a poor way to reformat a file you intend to keep editing by hand.

Choosing Between Them

JSON is the better choice for anything a machine writes or transmits: it is unambiguous, universally supported, and has no whitespace sensitivity to get wrong. YAML earns its place in files humans edit, CI pipelines, Kubernetes manifests, application configuration, where comments and readability are worth the extra care indentation demands.

This tool uses js-yaml, an MIT-licensed parser, and runs entirely in your browser. Nothing you paste is transmitted or stored, which matters given how often YAML configuration contains credentials. Note also that a very large document is parsed into memory in one go, so multi-megabyte files may be slow on a constrained device.

Frequently Asked Questions

Is YAML a superset of JSON?
Effectively yes for YAML 1.2, valid JSON is valid YAML. The reverse does not hold, since YAML has comments, anchors and multiple documents that JSON cannot express.
Why did my comments disappear?
JSON has no syntax for comments, so they are discarded on conversion. This is the main reason a YAML-to-JSON-to-YAML round trip is lossy.
Why did my version number become a number?
YAML converts unquoted values that look numeric. A value like `1.0` becomes a float; quote it to keep it a string.
Can I use tabs for YAML indentation?
No. YAML forbids tabs for indentation and will report a parse error. Use spaces, conventionally two per level.
What happens to anchors and aliases?
They are expanded, so the referenced content appears in full at each use. The reference itself cannot be represented in JSON.
Can it convert multiple YAML documents?
A single JSON value cannot hold multiple documents, so only the first is converted when a stream contains `---` separators.
Is my data sent anywhere?
No. Conversion happens entirely in your browser and nothing you paste is transmitted or stored.

Explore more in Developer

View all →