JSON to YAML Converter: How to Convert JSON to YAML Online Free

July 31, 20267 min read

JSON and YAML represent the same structured data in very different ways. JSON is explicit and strict — every string is quoted, every structure is delimited by braces and brackets. YAML is clean and minimal — indentation replaces delimiters, most strings need no quoting, and you can add comments anywhere.

This guide walks through how to convert between the two formats, explains the key syntax differences with concrete examples, and covers the gotchas that catch developers off guard.

Why Convert JSON to YAML?

The most common reason is human readability. YAML is significantly easier to read and write by hand, which is why it dominates in configuration files. Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Ansible playbooks almost universally use YAML. The comment support alone is a major advantage — you can document why a setting exists, which is impossible in standard JSON.

Key Syntax Differences

FeatureJSONYAML
Object delimiters{ }Indentation
Array delimiters[ ]- prefix per item
String quotingAlways requiredOptional for simple strings
CommentsNot supported# to end of line
Multi-line stringsEscaped Block scalars: | or >
Nullnullnull, ~, or empty

Step-by-Step Conversion Example

JSON configuration for a web application:

{
  "app": {
    "name": "MyApp",
    "version": "2.1.0",
    "debug": false,
    "port": 8080,
    "database": {
      "host": "localhost",
      "port": 5432,
      "name": "myapp_prod",
      "ssl": true
    },
    "allowed_origins": [
      "https://myapp.com",
      "https://www.myapp.com"
    ],
    "feature_flags": {
      "new_dashboard": true,
      "beta_api": false
    }
  }
}

The equivalent YAML:

# Web application configuration
app:
  name: MyApp
  version: "2.1.0"   # Quoted to preserve as string
  debug: false
  port: 8080
  database:
    host: localhost
    port: 5432
    name: myapp_prod
    ssl: true
  allowed_origins:
    - https://myapp.com
    - https://www.myapp.com
  feature_flags:
    new_dashboard: true
    beta_api: false

What changed: the outer braces are gone, most string quotes are gone, array items use - prefix, and comments are now possible.

Converting Arrays

JSON array:

{"colors": ["red", "green", "blue"]}

YAML block sequence (most readable):

colors:
  - red
  - green
  - blue

YAML flow sequence (compact — identical to JSON syntax, valid YAML):

colors: [red, green, blue]

Converting Nested Objects

# JSON
{
  "server": {
    "tls": {
      "enabled": true,
      "cert": "/etc/ssl/cert.pem",
      "key": "/etc/ssl/key.pem"
    }
  }
}

# YAML
server:
  tls:
    enabled: true
    cert: /etc/ssl/cert.pem
    key: /etc/ssl/key.pem

The YAML Norway Problem and Other Pitfalls

YAML 1.1 (used by many older tools including PyYAML < 6.0) automatically converts certain bare strings to booleans:

# YAML 1.1 treats these as booleans — dangerous!
country: NO     # parsed as false  (Norway problem)
enabled: YES    # parsed as true
mode: on        # parsed as true
switch: off     # parsed as false

In YAML 1.2 only lowercase true and false are booleans. To be safe across parsers, always quote ambiguous values:

country: "NO"
mode: "on"

Other common pitfalls:

Convert JSON to YAML Online — Free

IRJSON's Convert tool handles both directions with one click, entirely in your browser:

Reverse: YAML to JSON

Converting YAML back to JSON discards YAML-specific features: comments are removed, anchors and aliases are resolved and inlined, bare strings get double-quoted, and block scalars become escaped JSON strings. IRJSON handles this automatically.

When to Keep JSON vs Switch to YAML

Keep JSON when:

Switch to YAML when:

Frequently Asked Questions

Is YAML valid JSON?

No. A YAML document is not valid JSON. YAML 1.2 is designed so that any valid JSON is also valid YAML, but the reverse is not true: YAML's comments, unquoted strings, and indentation structure are all invalid in JSON.

What tools convert JSON to YAML?

IRJSON's free Convert tool works at irjson.com/convert — no sign-up, 100% in your browser. Programmatically: js-yaml in JavaScript/Node.js, PyYAML or ruamel.yaml in Python, or the yq command-line tool.

What is the YAML Norway problem?

YAML 1.1 treats bare NO (Norway's ISO 3166-1 country code) as the boolean false. The full YAML 1.1 boolean set includes: y, yes, no, n, true, false, on, off (any case). YAML 1.2 fixes this by only recognising lowercase true and false. Quote ambiguous values to be safe across parsers.

Convert JSON to YAML instantly

IRJSON handles JSON ↔ YAML in your browser — free, no sign-up, 100% private.

Open Converter →