JSON to YAML Converter

Paste JSON to get clean, readable YAML for Kubernetes, Docker Compose, GitHub Actions or any config file. Free, and your data never leaves your browser.

Direction
YAML output

  
  
–

Converted with js-yaml 4 (YAML 1.2) in your browser. Nothing is uploaded.

How the JSON to YAML converter works

The converter reads your JSON with the browser's own JSON.parse, then writes it as block-style YAML with js-yaml 4.1.1. It converts as you type. Choose 2 or 4 spaces of indentation, then copy the result or download it as a .yaml file.

Objects become indented key-value mappings and arrays become lists that start with a dash, so {"app":{"name":"web","ports":[80,443]}} becomes app: ⏎ name: web ⏎ ports: ⏎ - 80 ⏎ - 443. Long lines are never wrapped, and repeated values are written out in full rather than as anchors, so the output is easy to read and diff.

Because everything happens in your browser, you can safely paste API responses, Terraform or CloudFormation output, or app settings that contain internal hostnames. Nothing is sent to a server.

Why some strings are quoted

YAML has fewer quotes than JSON, so a plain word can be read as something else. Older YAML 1.1 parsers, such as Python's PyYAML, turn yes, no and on into booleans and 012 into an octal number. To keep your data exactly the same in every parser, strings that could be misread are quoted: {"answer":"yes","country":"NO","zip":"012","version":"3.10","n":12} becomes answer: 'yes' ⏎ country: 'NO' ⏎ zip: '012' ⏎ version: '3.10' ⏎ 'n': 12.

Real numbers, true, false and null are written without quotes, because they mean the same thing in JSON and YAML. Strings with line breaks become readable block scalars: {"motd":"Line one\nLine two\n"} becomes motd: | ⏎ Line one ⏎ Line two.

Fixing invalid JSON

If the JSON cannot be parsed, you get the line and column of the problem (counted from 1) and the surrounding lines with a marker. For example, a missing colon gives “Line 2, column 6: Unexpected number in JSON at position 14”. Click Go to line to jump there.

The usual causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, and comments, none of which are allowed in strict JSON.

Tips for clean YAML

Use 2 spaces unless your project says otherwise. It is the most common style for Kubernetes, Docker Compose and GitHub Actions files.

Add comments afterwards. JSON has no comments, so the YAML starts without any. Adding a few short comments is one of the main reasons to switch a config to YAML.

Check the round trip. Switch the direction to YAML → JSON and your YAML is moved into the input, so you can confirm it converts back to the same data. You can also use our dedicated YAML to JSON converter, or search the output with the regex tester.

JSON to YAML Converter: frequently asked questions

Is this JSON to YAML converter free and private?

Yes. It is free with no sign-up and no limits, and the conversion runs entirely in your browser. Your JSON is never uploaded, so it is safe for configs and API responses that contain internal details.

How do I convert JSON to YAML?

Paste your JSON into the input box. The YAML appears on the right straight away. Choose 2 or 4 space indentation, then click Copy or Download .yaml. If the JSON has an error, the converter shows the line and column so you can fix it.

Why are some values like "yes" or "012" wrapped in quotes?

Older YAML 1.1 parsers, such as PyYAML, read yes, no, on and off as booleans and 012 as an octal number. Quoting these strings keeps them as text in every YAML parser, so your data does not change meaning when another tool reads the file.

Is valid JSON already valid YAML?

Yes. YAML 1.2 is a superset of JSON, so most YAML parsers can read a JSON file as it is. Converting to block-style YAML makes it easier for people to read and edit, removes most quotes and brackets, and lets you add comments.

How do I convert JSON to YAML on the command line?

With yq (version 4), run: yq -P file.json, or yq -o=yaml file.json. With Python and PyYAML installed, run: python -c "import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False))" < file.json.

Can I convert YAML back to JSON?

Yes. Choose YAML → JSON at the top of the tool, or use the separate YAML to JSON converter page, which also handles files with several documents separated by ---.