Map Extract
Free tool

YAML to JSON, and back again

Settings files for automations, website builders and outreach scripts are often written in YAML, while the tool you want to paste them into expects JSON, or the other way round. Switch the direction, paste, and copy the result.

Runs in your browser. Nothing you enter is uploaded.

Example: an outreach schedule written by hand

A freelancer keeps the settings for a weekly outreach routine in a small YAML file so she can leave comments for herself. The automation platform she uses wants JSON. Converting it with 2-space indent dropped the comment line, kept 40 as a number and false as a boolean, kept the quoted time as text and turned the two-line | block into one string with line breaks.

Going the other way, from that JSON back to YAML, the list of towns came out as indented - items rather than the one-line [...] form she had typed. Both forms mean the same thing.

Input
# Outreach campaign settings
campaign: Bury bakeries Q1
daily_cap: 40
send_window: "09:00-16:00"
paused: false
towns: [Bury, Ramsbottom, Radcliffe]
signature: |
  Grace at Hollin Supplies
  0161 496 0321
Result
{
  "campaign": "Bury bakeries Q1",
  "daily_cap": 40,
  "send_window": "09:00-16:00",
  "paused": false,
  "towns": ["Bury", "Ramsbottom", "Radcliffe"],
  "signature": "Grace at Hollin Supplies\n0161 496 0321\n"
}

Converting in either direction

  1. Pick the direction

    Choose YAML to JSON or JSON to YAML. Switching loads a matching sample so you can see what each side looks like.

  2. Paste or open your file

    Type into the box or press Open a file for a .yaml, .yml, .json or .txt file. The result updates as you type.

  3. Set the indent

    Choose 2 or 4 spaces. When producing JSON you can also pick Minified to get a single line.

  4. Fix any error, then copy

    A tick shows a clean conversion. Otherwise the message names the line and the problem. Copy the output or download it as data.json or data.yaml.

What the YAML side supports

FeatureSupported?
Nested mappings and lists with - itemsYes
Comments starting with #Yes (dropped in JSON)
Single and double quoted stringsYes
One-line [lists] and {maps}Yes
Multi-line | (keep line breaks) and > (fold into one line) blocksYes
Anchors (&name), aliases (*name) and tags (!!str)No, refused with the line number
Several documents separated by ---No, convert one at a time
Tabs used for indentationNo; YAML itself forbids them

Values that change type by surprise

Unquoted values are read as numbers, booleans or null where they look like one: 40 becomes a number, true a boolean, ~ and null become null, and 1e3 becomes 1000. Words such as yes and no stay as text, following the current YAML standard, and so do values with a leading zero such as 007 or a phone number. When converting JSON to YAML, strings that YAML could misread, like "yes" or "true", are quoted so they come back as text.

Questions people ask

How do I convert a YAML file to JSON?

Choose YAML to JSON, paste the YAML or open the .yaml or .yml file, and the JSON appears below. Pick 2 or 4 spaces for readable output or Minified for one line, then copy it or download data.json. If the YAML has a mistake, the line number and reason are shown instead.

Why do I get an unexpected indentation error?

Usually a line is indented more than its parent without being a new key or list item, often because a long plain value was wrapped onto the next line. YAML only allows that inside a | or > block or quotes. Mixing tabs and spaces causes a similar error, since tabs are not allowed for indentation.

Are YAML comments kept?

Not in JSON, because JSON has no comment syntax. They are read and skipped when converting YAML to JSON, so converting back to YAML will not bring them back. Keep your original YAML file if the comments matter to you or your team.

Can I use this for Docker Compose or GitHub Actions files?

Simple ones, yes. Larger configuration files often use anchors and aliases to reuse blocks, or tags such as !reference, and those are refused here with the line number rather than converted wrongly. Expand them by hand first, or use a full YAML library for those files.

Where your data goes

Conversion happens in your browser with code loaded on this page. Settings, keys or tokens inside the YAML or JSON are not sent anywhere, though as a habit it is wise to remove real passwords and API keys before pasting configuration into any website.

Checked against the tool on

Top