Home › JSON to YAML Converter

JSON to YAML Converter Online

Instantly convert JSON to YAML with proper formatting. Free, private, no signup — your data stays in your browser.

Convert JSON to YAML →

JSON vs YAML: Side-by-Side Example

JSON:

{
  "name": "Alice",
  "age": 30,
  "active": true,
  "roles": [
    "admin",
    "editor"
  ],
  "address": {
    "city": "NYC",
    "zip": "10001"
  }
}

YAML:

name: Alice
age: 30
active: true
roles:
  - admin
  - editor
address:
  city: NYC
  zip: '10001'

YAML is 25% shorter and more readable — no braces, no quotes for most strings.

JSON to YAML Type Mapping

JSON YAML Notes
"string"stringQuotes omitted unless ambiguous
4242Same
true / falsetrue / falseSame (also yes/no in YAML)
nullnull or ~Both are valid YAML null
[1, 2, 3]- 1\n- 2\n- 3Block sequence style
{}Indented block mappingNo braces needed

Convert JSON to YAML in JavaScript

// Using js-yaml library (npm install js-yaml)
import yaml from 'js-yaml';

const jsonData = { name: 'Alice', age: 30, roles: ['admin', 'editor'] };
const yamlString = yaml.dump(jsonData);
console.log(yamlString);
// name: Alice
// age: 30
// roles:
//   - admin
//   - editor

Convert JSON to YAML in Python

import json, yaml  # pip install pyyaml

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

with open('data.yaml', 'w') as f:
    yaml.dump(data, f, default_flow_style=False, allow_unicode=True)

# Or as a string:
yaml_str = yaml.dump(data, default_flow_style=False)
print(yaml_str)

Common YAML Use Cases

Frequently Asked Questions

Is all JSON valid YAML?

Yes. JSON is a valid subset of YAML 1.2. Any JSON file can be parsed by a YAML parser. However, YAML has additional features (comments, anchors, aliases, multi-line strings) that JSON does not support.

Why does YAML quote some strings but not others?

YAML quotes strings that could be misinterpreted as other types. For example, "10001" (a ZIP code) must be quoted in YAML because unquoted 10001 would be parsed as an integer. Similarly, "true", "null", and "yes" need quotes to be treated as strings.

Which should I use — JSON or YAML for config files?

YAML is preferred for config files that humans edit because it supports comments and is less noisy. JSON is preferred for programmatic config (like package.json) because it is stricter and easier to parse with any language. When in doubt for Kubernetes, CI/CD, or Docker — use YAML.

Convert JSON to YAML now

Free, instant, private — no signup required.

Open JSON to YAML →

Also useful: JSON to CSV | JSON to XML | JSON vs XML | JSON Formatter