Skip to content
PocketDesk
Your files are processed on your device, never uploaded

YAML to JSON

  • On device
Input
Ln 1, Col 11 line0 BUTF-8

Paste, drop or open a file in Input to see the result here.

Waiting for input
  • ⌘Enter Format
  • ⌘⇧M Minify
  • ⌘⇧C Copy result
  • ⌘F Find in result
  • Esc Exit full screen
  • Use Ctrl instead of ⌘ on Windows and Linux

How to convert YAML to JSON

  1. Paste your YAML into the Your YAML box, or open a .yaml or .yml file.
  2. Choose the indentation, or Minified for a single line.
  3. Read the JSON in the result box. Select Copy or Download to save data.json.

If the YAML is not valid, you see the problem with its line and column instead. A common cause is a mix of tabs and spaces, or a list item that is not lined up with its siblings.

What the converter does

YAML describes the same kinds of data as JSON: mappings (objects), sequences (arrays), strings, numbers, booleans and null. The converter reads your YAML with the safe loader, then writes the same data as JSON.

  • Anchors (&name) and aliases (*name) are expanded into full copies.
  • Several documents in one file, separated by ---, become a JSON array.
  • Comments and formatting are dropped, because JSON cannot store them.
  • Values such as yes and on are read as text, not as booleans, following the YAML 1.2 rules.
  • Dates stay as the text you wrote.

Because the loader is safe, a tag such as !!js/function is rejected with an error rather than being run.

Why convert YAML to JSON

Many APIs, validators and JavaScript tools accept only JSON, while people prefer to write configuration in YAML. Converting lets you test a config against a schema, send it in a request body, or load it in code without a YAML library.

Tips

  • Validate the output with the JSON validator before sending it to an API.
  • Turn it back into YAML with JSON to YAML.
  • Quote values that must stay text, such as version numbers like "1.10", which would otherwise become the number 1.1.
  • Empty YAML, or a file with only comments, gives an empty result rather than an error.

Privacy

Kubernetes files, CI configs and app settings often hold secrets. This tool runs only in your browser. Nothing is uploaded, stored or logged.

Questions

Is it safe to paste untrusted YAML?

Yes. It uses the safe loader, which does not run code or accept custom tags, and everything happens in your browser.

What happens with several documents separated by ---?

They are returned as a JSON array with one item per document.

Why do I get an error about indentation?

YAML uses spaces to show structure and tabs are not allowed. The message shows the line and column to check.

Are anchors and aliases supported?

Yes. An alias such as *base is replaced by a copy of the anchored value.

Are comments kept?

No. JSON cannot hold comments, so they are dropped.

More developer tools