Skip to the JSON editor
JSON Formatter Viewer

YAML to JSON

input.yaml

output.json

The JSON appears here.

or drop a .yaml file into the left pane

Waiting for input

What converts cleanly

Mappings become objects, sequences become arrays, and scalars keep their type. Anchors and aliases are resolved during parsing, so a YAML file that reuses a block through&defaults and *defaults produces JSON with the value expanded in both places:

defaults: &defaults
  retries: 3
staging:
  <<: *defaults
  host: stage.example.com

{
  "defaults": { "retries": 3 },
  "staging": { "retries": 3, "host": "stage.example.com" }
}

What cannot survive the trip

  • Comments. JSON has no syntax for them. This is the main reason to keep the YAML file rather than converting it permanently.
  • Key order intent. Order is preserved in the output text, but JSON objects are formally unordered, so nothing downstream is obliged to respect it.
  • Typed tags. Custom tags such as !!timestamp or application tags collapse to their string form, since JSON has only six types.

Reading the errors

YAML failures are almost always structural rather than typographical: a key indented one space too far, a list item that lines up with its parent, or a tab where spaces belong. When parsing fails, the status bar reports the line and column the parser stopped at, which is where the indentation stopped agreeing with the block above it.

Next steps

Once converted, the tree viewer is the fastest way to check that a deeply nested config came across the way you expected, andJSON to YAML converts back.

Common questions

What happens to my comments?

They are dropped. JSON has no comment syntax, so there is nowhere to put them. If the comments matter, keep the YAML as the source of truth and treat the JSON as a build artefact rather than a replacement.

My file has several documents separated by ---. Does that work?

Yes. A multi-document stream becomes a JSON array with one element per document, because JSON has no equivalent of a document separator. A single document converts to its value directly, not to a one-element array.

Why does it complain about tabs?

YAML forbids tabs as indentation — this is in the specification, not a limitation here. Editors that insert tabs are the most common cause of an otherwise valid-looking file failing to parse. Convert the leading tabs to spaces and it will load.

Are dates and timestamps preserved?

They become strings. JSON has no date type, so an unquoted YAML timestamp is emitted as its text form rather than as an object. Numbers, booleans, and null map across exactly.

The rest of the toolkit

Same engine, same privacy — every page runs entirely in your browser.