JSON to YAML.

Convert JSON into clean, human-readable YAML in your browser. Deterministic ordering, sensible quoting, full client-side processing.

Processed in your browserNo upload, no signup

JSON input

0 lines · 0 chars

YAML output

0 lines · 0 bytes

Why convert JSON to YAML?

JSON and YAML serve different purposes in the developer ecosystem. JSON is the standard for API data exchange — it's compact, machine-friendly, and supported everywhere. YAML is preferred for configuration files — it supports comments, is easier to read, and is the format used by Kubernetes, Docker Compose, Ansible, and many CI/CD tools.

Converting JSON to YAML is common when you have machine-generated data that needs to become a human-editable configuration file. For example, exporting API schemas from JSON and converting them to YAML for Kubernetes manifests, or transforming JSON environment configs into YAML for Docker Compose.

How the conversion works.

The converter parses your JSON into a JavaScript object, then serialises it as YAML using js-yaml. The output uses 2-space indentation, preserves your original key order, and handles all JSON types correctly: strings, numbers, booleans, nulls, arrays, and nested objects.

If your JSON is invalid, the converter displays the exact error with line and column information. The input is preserved so you can fix the issue and reconvert. The converter also handles edge cases like empty arrays, null values, and deeply nested structures.

JSON vs YAML: when to use which.

Use JSON for APIs. JSON is the universal format for REST and GraphQL APIs. It's compact, has no ambiguity, and every programming language has native JSON support.

Use YAML for configuration. YAML supports comments, is easier to read by humans, and is the standard for Kubernetes, Docker Compose, Ansible playbooks, and CI/CD pipeline definitions.

Convert when bridging. When your API generates data that needs to become a configuration file, or when you need to move data between systems that use different formats, this converter bridges the gap instantly.

Key syntax differences.

JSON uses double quotes for all string values, requires commas between items, and does not allow trailing commas. YAML uses no quotes for simple strings (though quotes are allowed), uses indentation for structure, and allows comments with #. JSON arrays use square brackets [1, 2, 3]; YAML arrays use dashes - 1 on separate lines. Both formats support nested objects, but the visual structure differs significantly — YAML reads like a document, while JSON reads like code.

One important subtlety is type inference. JSON has explicit types: true is boolean, 1 is a number, "1" is a string. YAML also distinguishes types but has edge cases — the value yes is a boolean in YAML 1.1 but a string in YAML 1.2. This converter uses YAML 1.2 semantics where possible, but be aware of this difference when working with config files that originated from different YAML parsers.

YAML anchors, aliases, and tags.

YAML supports anchors (&default) and aliases (*default) for reuse — similar to variables in programming. It also supports type tags like !!str and !!int to explicitly declare types. This converter preserves anchors and aliases during conversion, so a JSON object with repeated structures can be converted to YAML with anchors for DRY configuration files. However, JSON has no equivalent concept, so anchors are only meaningful when round-tripping YAML through JSON and back.

Multiline strings are another YAML advantage. The | (literal) and > (folded) operators let you write long strings without escaping newlines. JSON requires \n for every newline, making large text blocks hard to read. When converting JSON strings with escaped newlines to YAML, the converter outputs clean multiline syntax.

Common conversion pitfalls.

Key order. JSON objects are unordered by specification, but most parsers preserve insertion order. This converter maintains the order from your input JSON, so the YAML output has the same key sequence. Empty values. null in JSON becomes null in YAML. Empty objects {} become {}. Empty arrays [] become []. These are preserved correctly.

Numeric edge cases. Very large numbers (> 2^53) lose precision in JavaScript. YAML has the same limitation. If your JSON contains numbers like 9007199254740993, consider representing them as strings to avoid silent rounding. The converter handles standard numbers correctly but cannot circumvent JavaScript's numeric precision limits.

Your input is processed locally and isn't uploaded for processing. Verify by opening DevTools → Network — there are no requests carrying your data.

JSON to YAML examples.

// Simple object

name: John
age: 25
active: true
{
  "name": "John",
  "age": 25,
  "active": true
}

// Nested object

user:
  name: John
  address:
    city: New York
    country: USA
{
  "user": {
    "name": "John",
    "address": {
      "city": "New York",
      "country": "USA"
    }
  }
}

// Array of items

languages:
  - JavaScript
  - Python
  - Go
{
  "languages": [
    "JavaScript",
    "Python",
    "Go"
  ]
}

Frequently asked questions.

How to convert JSON to YAML?

Paste your JSON into the left panel and the YAML output appears instantly on the right. You can also drag and drop a .json file, or click Upload. The conversion runs entirely in your browser — no server needed.

How do I convert JSON to YAML?

Simply paste your JSON into the input editor. The converter processes it in real-time and displays clean, human-readable YAML on the right. Click Copy or Download to save the result.

When to use JSON vs YAML?

JSON is ideal for web APIs, configuration files consumed by applications, and machine-generated data. YAML is better for human-edited configs, CI/CD pipelines, Kubernetes manifests, and documentation because it supports comments and is easier to read.

What tools can I use to convert JSON to YAML?

This free online converter works instantly in your browser. For CLI tools, try yq (yq -P file.json), Python with PyYAML, or Node.js with js-yaml. VS Code has extensions like "JSON to YAML" for quick conversion.

How to convert JSON to YAML in Python?

Use PyYAML: import json, yaml; data = json.load(open("file.json")); yaml.dump(data). For files: yaml.dump(json.load(open("input.json")), open("output.yaml", "w")). Our online tool does this without any installation.

How to convert JSON to YAML in VS Code?

Install the "JSON to YAML" extension from the marketplace, or use this online converter. For command-line: yq -P input.json > output.yaml. Many code editors also have built-in conversion plugins.

What are the differences between JSON and YAML?

JSON uses braces and brackets with quoted strings; no comment syntax. YAML uses indentation with plain text; supports comments (#), anchors, and multiline strings. JSON is more compact; YAML is more human-readable.

How does JSON compare to YAML in terms of readability?

YAML is generally more readable because it avoids brackets and quotes, using indentation instead. However, YAML's whitespace sensitivity can cause errors. JSON is more verbose but unambiguous and machine-friendly.

How does TOML compare to JSON and YAML?

TOML is a configuration format that is more human-readable than JSON but stricter than YAML. It uses key-value pairs with explicit types. JSON is universal for data exchange; YAML excels for complex nested configs; TOML is ideal for simple config files.

Is my JSON data sent to a server?

No. The conversion runs entirely in your browser using JavaScript. Your data never leaves your device — you can verify this by opening the Network tab in DevTools.

Does the converter preserve key order?

Yes. We use js-yaml which preserves the iteration order of the parsed JSON object.

What if my JSON is invalid?

You will see an error message with the exact line and column where the parse failed, plus a hint describing the most likely fix. Your input is preserved so you can correct it.

Related tools.