JSON to YAML Converter

Paste JSON and get clean, readable YAML as you type.

Converted in your browser. Your JSON is never uploaded. How we know

Reformat CtrlEnter

0 lines
or drop a .json file
YAML
 

YAML will appear here as you type.

Ln 1, Col 1 Spaces: 2 UTF-8
Processed in this tab

Processed in this tab

How to convert JSON to YAML

Converting JSON to YAML here takes three steps, and nothing leaves your browser.

  1. Paste or open. Paste JSON into the converter, use Open file for a .json file, or drop the file onto the JSON pane.
  2. Pick an indent. Choose 2 or 4 spaces. The YAML updates as you type.
  3. Take it with you. Copy the YAML, download it as a .yaml file, or make a share link.

If the JSON has a mistake, such as a trailing comma or single quotes, the converter gives you the line and column, says what is wrong, and keeps your last valid YAML on screen while you fix it.

What the YAML looks like

Objects become maps and arrays become lists, in block style with one item per line. These are the cases where the converter has to make a choice.

Key order {"b": 1, "a": 2}
Kept as written, never sorted. One exception comes from JavaScript itself: keys that are whole numbers, like "10", move to the front in numeric order.
Strings that look like another type "yes" "123" "2026-09-24"
Quoted in the YAML, so a YAML parser still reads them as text and not as a boolean, a number or a date.
Multi-line strings "line one\nline two"
Written as a block (| or |-) with one line of text per line, instead of one long line full of \n.
Long strings "a very long line…"
Never folded. A long value stays on one line, so nothing is re-wrapped.
Empty objects and arrays {} []
Written as {} and [], the only way YAML can show an empty collection.
null "pool": null
Written as null.
Very large integers 9007199254740993
Numbers above 2^53 get a warning, because JavaScript can’t hold them exactly.

Convert JSON to YAML in Python

Install PyYAML with pip install pyyaml, read the file with json.load and write it with yaml.safe_dump.

convert.py
import json
import yaml

with open("config.json") as f:
    data = json.load(f)

print(yaml.safe_dump(data, sort_keys=False, allow_unicode=True), end="")

sort_keys=False keeps the keys in the order of the JSON file; without it PyYAML sorts them alphabetically. allow_unicode=True writes characters like é as they are instead of as escape codes.

Tested with Python 3.11.3 and PyYAML 6.0.1

Convert JSON to YAML on the command line

Two ways to do it in a terminal. Each one reads config.json and prints YAML, so redirect it with > to save a file.

python3 -c 'import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False, allow_unicode=True), end="")' < config.json

Tested with Python 3.11.3 and PyYAML 6.0.1

The Node.js command runs the js-yaml package's own command-line tool through npx, so there is nothing to install globally. It accepts either format: given JSON it prints YAML, and given YAML it prints JSON.

More YAML and JSON tools

Every tool here runs in your browser, with the same editor, share links and plain-English errors.

Frequently asked questions

How do I convert JSON to YAML?

Paste your JSON into the left pane or open a .json file. The YAML appears on the right as you type. Pick 2 or 4 spaces of indent, then copy the result or download it as a .yaml file. It all runs in your browser, so there is nothing to install and no sign-up.

Is JSON already valid YAML?

Almost always. YAML 1.2 was designed so that nearly all JSON is also valid YAML, which means most YAML tools will accept a JSON file as it is. People convert anyway because block-style YAML is easier to read and edit by hand, and because YAML allows comments.

Why are some strings quoted in the YAML?

To keep them strings. Unquoted, yes or true would be read as a boolean, 123 as a number and 2026-09-24 as a date. If the JSON had them in quotes they were text, so the converter keeps the quotes. Ordinary text is written without quotes.

Does converting JSON to YAML lose any data?

No. Every JSON value has a YAML form: objects become maps, arrays become lists, and strings, numbers, booleans and null carry over. Key order is kept. The one thing to watch is integers above 2^53, which JavaScript can’t hold exactly. The converter warns you when it finds one.

What does the converter do with invalid JSON?

It tells you the line and column of the first problem, what is wrong, and how to fix it. It recognizes the usual causes: a trailing comma, single quotes, a key without quotes, a missing comma, a comment, or an unclosed bracket or string. Your last valid YAML stays on screen while you fix it.

Is my JSON uploaded anywhere?

No. Conversion runs in your browser tab, and the page never sends your JSON in any request. Share links keep the content after the # in the URL, which browsers don’t send to servers. An automated test checks this on every build of the site.