Skip to content
FlipConverto home

JSON to YAML Converter

Convert JSON to YAML, or YAML back to JSON, in your browser. Strings such as yes, no, 0123 and 2024-01-31 are quoted so a YAML parser keeps them as text, and YAML errors come with a line number.

Loading JSON to YAML Converter…

Runs entirely in your browser. What you enter stays on your device — nothing is sent to a server. Verify it yourself

How do you convert JSON to YAML safely?

Rewrite objects as indented key: value lines and arrays as - items, and quote any string that YAML would read as another type — yes, no, null, numbers such as 0123, and dates. This converter does both and writes multi-line strings as | blocks.

Cost
Free, no limits
Upload
None — runs on your device
Sign-up
Not required
Works offline
Yes, once loaded

How to convert JSON to YAML

  1. Choose the direction

    Pick JSON → YAML or YAML → JSON at the top.

  2. Paste or open the file

    Paste into the box, use Open file for a .json, .yaml or .yml file, or Load sample to see quoting in action.

  3. Read any errors

    Invalid input gets a message with the line number and the cause; values JSON cannot hold exactly are listed above the result.

  4. Copy or download

    Copy the result, download it, or press Convert the YAML back to check the round trip.

Examples

  • {"country": "NO", "zip": "01234", "on": true}country: 'NO' zip: '01234' 'on': true

    Unquoted, NO and on would become false and true in a YAML 1.1 parser.

  • {"script": "npm ci\nnpm test\n"}script: | npm ci npm test

    A trailing newline gives |; none would give |-.

  • ports: [80, 443] name: web{"ports": [80, 443], "name": "web"}

    Inline lists are read as well as dash lists.

Key features of the JSON to YAML Converter

  • Writes block-style YAML with two-space indentation, keeping key order
  • Quotes strings that YAML 1.1 or 1.2 would read as booleans, null, numbers or dates
  • Writes multi-line strings as | literal blocks with the right chomping indicator
  • Reads YAML mappings, lists, inline [ ] and { }, quoted values, | and > blocks and comments
  • Refuses anchors, aliases, tags and multi-document files with a line number instead of guessing
  • Runs entirely in your browser, on input up to 5 MB

What it converts

Directions

  • JSON → YAML
  • YAML → JSON

YAML it reads

  • Block mappings and lists
  • Inline [ ] and { }
  • Plain, 'single' and "double" quoted values
  • | and > block scalars
  • Comments, --- and ...

Refused with a message

  • Anchors and aliases
  • Tags
  • Multiple documents
  • Tab indentation

When should you use this?

  • Turning a JSON API response or package.json snippet into YAML for a Kubernetes, Docker Compose or GitHub Actions file.
  • Reading a YAML configuration as JSON to check exactly which types a parser will see.
  • Converting YAML test fixtures into JSON for a tool that only accepts JSON.

Limitations

  • Anchors, aliases, merge keys, tags, explicit ? keys and multi-document files are not supported; they are reported, not converted.
  • Comments in YAML are dropped when converting to JSON, because JSON has no comments.
  • Numbers follow JavaScript: integers beyond 2^53 lose precision (a warning names the line), and .inf and .nan become null.
  • Input is limited to 5 MB and 100 levels of nesting.

Troubleshooting

"unexpected indentation" on a line that looks fine

The line is indented more than the keys above it but follows a value on the same line. Line it up with its sibling keys, or move the value onto its own indented lines.

A long number changed in the JSON

JSON numbers in JavaScript are exact only up to 9,007,199,254,740,991. Quote the value in the YAML so it stays a string.

Common mistakes to avoid

  • Indenting YAML with tabs. YAML only allows spaces; the converter reports the line.
  • Writing key:value without a space. In YAML that is a single string, not a key and a value.
  • Expecting yes or on to become true in JSON. Under YAML 1.2 they are strings; write true or false.

Pro tips

Tips for better results

  • Quoting

    Quote leading zeros and country codes yourself

    Quote country codes, version numbers like 1.10 and anything with a leading zero by hand in YAML you write yourself — the same rules this converter applies.

  • Checking

    Convert back to prove the YAML means the same

    Use Convert the YAML back after JSON → YAML: if the JSON that comes back matches what you started with, the YAML means the same thing.

  • Anchors

    Expand anchors before converting

    If a file uses anchors to share settings, expand them in your editor or with your deployment tool first, then convert the result.

Why some values are quoted

YAML guesses the type of an unquoted value. Older YAML 1.1 parsers — still the default in many tools — read yes, no, on and off as booleans, 0123 as a number, 12:30 as a base-60 number and 2024-01-31 as a date. The classic casualty is the country code for Norway, NO, which turns into false.

When this YAML converter writes YAML it checks every string against those patterns, plus empty strings, leading or trailing spaces, and characters that mean something in YAML (#, : , -, [, &, *, ! and others). Anything that could be misread is single-quoted; text with control characters is double-quoted with escapes. Everything else is left plain, so the output stays readable.

Multi-line strings

A string with line breaks is written as a literal block scalar (|), which keeps every line exactly. The suffix records how the string ended: |- means no final newline, | one, and |+ more than one. If the first line starts with a space an indentation digit is added (|2) so the leading spaces survive.

What the YAML reader accepts

YAML → JSON handles the parts of YAML that configuration files use: nested mappings and lists, lists written at the same indentation as their key, inline [a, b] and {a: 1} collections, plain, single-quoted and double-quoted values (with escapes such as \n and é), literal (|) and folded (>) blocks, comments, a leading --- and a closing ....

Values are typed by the YAML 1.2 core schema: true/false, null/~, integers (including 0x hex and 0o octal) and decimals. Under 1.2, yes and dates stay strings. Anchors (&), aliases (*), merge keys that use them, tags (!!str), explicit ? keys and files with several --- documents are refused with a message naming the line — rather than converted wrongly.

Sources

Privacy

The JSON to YAML Converter runs entirely in your browser. What you enter and the result it produces stay on your own device — nothing is sent anywhere, because nothing needs to be.

You can confirm this rather than take our word for it: open your browser’s developer tools, watch the Network tab, and use the tool. No request carries your input. It also keeps working with the connection off.

Details are in the privacy policy.

What next?

Find the exact line of a JSON syntax error before converting.

Validate JSON first

JSON to YAML Converter — questions

How do I convert JSON to YAML?

Paste the JSON into the box with JSON → YAML selected. The YAML appears as you type; copy it or download it as a .yaml file. If the JSON is invalid the error says why instead.

Why are some of my strings in quotes in the YAML?

Because without quotes a YAML parser would read them as something else: yes and no as booleans, 0123 as a number, 2024-01-31 as a date. Quoting keeps them strings in every parser, including older YAML 1.1 ones.

Does it support anchors and aliases?

No. Anchors (&name), aliases (*name), merge keys built on them and tags (!!str) are refused with the line number, because expanding them correctly needs a full YAML implementation. Replace each alias with a copy of its value and convert again.

Why did yes stay a string when converting YAML to JSON?

The reader follows YAML 1.2, where only true and false are booleans. YAML 1.1 parsers would turn yes, no, on and off into booleans; if you need that, change them to true or false in the YAML first.

Can I convert a Kubernetes manifest with several documents?

One document at a time. A file with several documents separated by --- is refused with a message; paste each document separately.

Part of Developer Tools · Browse every tool