How to convert YAML to JSON

Open the free YAML to JSON converter. Paste a YAML document, read the JSON beside it, and copy the result. You can also reverse the direction and turn JSON into YAML. The parser runs in your browser. There is no sign-up.

Convert a document

  1. Open the YAML to JSON converter.
  2. Paste your YAML into the left box, or click Sample to load an example.
  3. Read the JSON on the right. It is indented with two spaces.
  4. Click Copy to put that JSON on your clipboard, or Download to save a file.
  5. Click Clear when you want an empty editor.

If the YAML is rejected

The message above the editors quotes the first problem, including a line and column when the parser has one. Indent with spaces, not tabs. Close quotes, brackets, and braces. Then edit the YAML and the JSON updates on its own.

A few values change type if you leave them unquoted:

  • true, false, null, ~, and numbers become JSON booleans, null, and numbers. True and FALSE are booleans too.
  • yes, no, on, and off stay strings. This tool follows YAML 1.2, not the older YAML 1.1 rule that treated those words as booleans.
  • 1.10 becomes 1.1, and 0123 becomes 123. Quote them ("1.10", "0123") when the digits matter.
  • An integer that does not fit in a JSON number is reported as an error instead of being rounded.
  • NaN and Infinity are rejected, because JSON cannot store them.

Turn JSON back into YAML

Choose JSON to YAML, then paste JSON on the left. The right side shows YAML. Comments cannot come back, because JSON never stored them. Invalid JSON produces an error instead of a partial document.

What the converter keeps and drops

  • Comments are removed.
  • Anchors and aliases are written out in full. A circular alias is rejected.
  • Merge keys (<<) are applied before the JSON is built.
  • Explicit !!timestamp values become ISO 8601 strings. Plain dates such as 2024-01-02 stay strings.
  • !!binary values are rejected rather than turned into a pile of numbers.
  • Several YAML documents in one paste (separated by ---) become a JSON array, one item per document. An empty document in that stream becomes null.

A short example

service: harbor
enabled: true
{
  "service": "harbor",
  "enabled": true
}

YAML to JSON online versus a CLI

A command-line converter is the better fit when the same file is converted on every build, in CI, or from a repository script. You can pin a version, read from disk, and fail the job when the file is invalid.

This site is the other case: a YAML to JSON online conversion for a snippet already on the clipboard. There is nothing to install, and the parser runs in the tab, so a one-off manifest does not need a project. Use a CLI when conversion is part of a pipeline. Use the browser when you want to inspect or copy a result once. Both directions, YAML to JSON and JSON to YAML, stay on the homepage converter.

Why bother

YAML is comfortable to edit by hand. JSON is what a lot of APIs, browsers, and command-line tools accept. Converting lets you keep a readable source file and hand over the JSON those tools ask for.