Skip to content
Aarrange

JSON to YAML

Paste JSON. Get YAML as you type. Nothing leaves your browser.

0
Lines
0
Keys
0
Errors
Input
Tab types a tab. Press Escape, then Tab, to leave the editor.
Result
The result shows here as you type.Try , or .
On this page

About JSON to YAML Converter

Updated

JSON to YAML Converter turns JSON (JavaScript Object Notation) into YAML (YAML Ain't Markup Language). Paste your JSON into the editor and the YAML shows in the Result pane as you type. Press Convert to jump to the YAML, then Copy or Download it.

The tool checks your JSON at the same time. When something is wrong, it rings the exact spot, gives the line and column, and says how to fix it. Format and Minify tidy the JSON itself. Summary counts the keys, depth and arrays, and Tree shows every key and value.

Customization

Open Options to set the YAML indent, double or single quotes, whether long text stays on one line, and sorting keys A to Z. The tool remembers your choices.

Common JSON to YAML conversions

Simple data structures

A JSON array of simple values, such as ["apple", "banana", "cherry"], becomes a YAML list:

YAML
- apple
- banana
- cherry

Nested objects

Nested JSON objects become indented YAML mappings. The structure stays exactly the same.

JSON
{
  "name": "John",
  "age": 30,
  "cars": {
    "car1": "Ford",
    "car2": "BMW"
  }
}
YAML
name: John
age: 30
cars:
  car1: Ford
  car2: BMW

Arrays of objects

JSON arrays of objects are common in many applications. They become YAML sequences of mappings:

JSON
[
  { "hobby": "swimming", "experience": 5 },
  { "hobby": "running", "experience": 3 }
]
YAML
- hobby: swimming
  experience: 5
- hobby: running
  experience: 3

Behind the scenes

The JSON is read by our own strict JSON parser, the same one as in the JSON Validator. The YAML is written by the yaml library, following the YAML 1.2 rules from yaml.org.

Other JSON resources

JSON to YAML FAQ

Why use a JSON to YAML converter?

Converting data by hand is slow and easy to get wrong. The converter turns JSON into YAML in one step, keeps every value and its type, and quotes text that YAML would otherwise read as something else.

What should I do if the conversion fails?

The converter only works on valid JSON. When the JSON has an error, the tool rings the exact spot, gives the line and column, and says how to fix it. Fix it, and the YAML appears.

What should I consider when converting JSON to YAML?

Keep these points in mind:

  • Since YAML 1.2, valid JSON is also valid YAML. YAML adds features that JSON does not have, such as comments, anchors and aliases.
  • YAML uses indentation for structure, so take care when you change the indents by hand.
  • Some text values look like other types in YAML, such as true, null or 1.0. When such a value is text in your JSON, the converter puts it in quotes so it stays text.
What is the difference between JSON and YAML?

Both store and send structured data. JSON uses brackets and quotes, and is strict and compact. YAML uses indentation, supports comments, and is easier for people to read and edit.

When should I choose YAML over JSON?

Choose YAML for configuration files that people read and edit, such as Kubernetes, Docker Compose or GitHub Actions files. Choose JSON for data that programs send to each other, such as API responses.

Can I convert YAML back to JSON?

Yes. Paste your YAML into the YAML Formatter and open its JSON tab.