YAML ↔ JSON

What Is the YAML to JSON Converter?

Convert between YAML and JSON in either direction. Nested maps, arrays, multi-line strings and anchors convert; YAML comments are dropped because JSON has no comment syntax.

Why Use This Tool?

YAML and JSON are both used for configuration and data interchange, but they have different strengths. This converter lets you switch between formats while preserving data structure and types.

How to Use This YAML JSON Converter

  1. Paste your YAML or JSON — Enter the data you want to convert into the input area.
  2. Select the direction — Choose YAML → JSON or JSON → YAML from the conversion toggle.
  3. Review the output — The converted output appears instantly with proper formatting and syntax highlighting.
  4. Copy the result — Click Copy to grab the converted data for your configuration files, API payloads, or documentation.

Worked example: the YAML values that change type

Most YAML-to-JSON surprises come from plain, unquoted values the parser has to guess a type for, and parsers don't all guess the same way. This tool uses js-yaml 4.1.0, which follows YAML 1.2's core schema. On October 12, 2026 we converted the same snippet with it and, for comparison, with PyYAML 6.0.3, which follows the older YAML 1.1 rules that many tools still use.

YAML lineThis tool (YAML 1.2) → JSONPyYAML (YAML 1.1)
country: NO"NO" (string)false
flag: yes / switch: on"yes" / "on" (strings)true / true
zip: 012341234 (number, leading zero lost)668 (read as octal)
time: 12:30"12:30"750 (base-60: 12×60+30)
version: 1.101.11.1
date: 2026-10-12"2026-10-12T00:00:00.000Z"a date object
big: 1234567890123456789012345678901234567000 (precision lost)exact
empty: and tilde: ~null, nullnull, null

The rule of thumb: quote anything that must stay a string. That covers postal codes and IDs with leading zeros, version numbers, dates you want as text, and long numeric IDs: zip: "01234", version: "1.10". The "Norway problem" (NO becoming false) and the yes/no/on/off booleans are YAML 1.1 behaviours. This tool treats them as strings, but a 1.1 parser elsewhere in your pipeline (PyYAML's default loader, older CI systems) won't, so quoting protects you everywhere.

Converting JSON back to YAML, the tool quotes exactly these ambiguous strings for you (flag: 'yes', country: 'NO', zip: '01234', version: '1.10'), so a round trip through this tool keeps them as strings.

What doesn't survive YAML → JSON

Comments are dropped, because JSON has no comment syntax. Anchors and aliases (&base / *base) are expanded into full copies. Block strings (| and >) become ordinary JSON strings, with \n wherever the YAML keeps a line break. Integers beyond 2⁵³ lose precision, because JavaScript numbers can't hold them exactly.

Related tools

Frequently Asked Questions

When should I use YAML vs JSON?
YAML is more human-readable and supports comments — ideal for config files (Docker Compose, CI/CD pipelines, Kubernetes). JSON is more universal for APIs and data interchange, and is natively supported by JavaScript.
Does YAML support comments?
Yes — YAML supports single-line comments with #. This is one of YAML's key advantages over JSON, which has no comment syntax.
Are there YAML features that don't convert to JSON?
Yes. Comments are dropped (JSON has none), anchors (&) and aliases (*) are expanded into full copies, and block strings (| and >) become normal JSON strings with \n for line breaks. Dates become ISO timestamps and very large integers lose precision, so quote values that must stay text.
What is the difference between YAML and JSON?+
Both are data serialization formats, but they serve different use cases. JSON uses braces and brackets with strict syntax, making it ideal for machine-to-machine data exchange. YAML uses indentation and natural syntax, making it more human-readable and preferred for configuration files. YAML supports comments; JSON does not.
Is YAML better than JSON?+
Neither is universally better — they serve different purposes. YAML is better for human-edited files (configs, CI/CD pipelines) because it's more readable and supports comments. JSON is better for data interchange (APIs, storage) because it's faster to parse, unambiguous, and universally supported by every programming language.
Can YAML files contain comments?+
Yes, YAML supports single-line comments using the # character. This is one of YAML's biggest advantages over JSON for configuration files — you can document settings, explain options, and leave notes for future maintainers directly in the file.
How do I convert YAML to JSON?+
Paste YAML into this tool and it instantly outputs the equivalent JSON. The conversion preserves all data types, nested structures, and arrays. YAML comments are stripped since JSON doesn't support them.
When should I convert between YAML and JSON?+
Convert YAML to JSON when your application requires JSON input (most APIs). Convert JSON to YAML when creating configuration files (Docker, Kubernetes, CI/CD) that benefit from YAML's readability and comments.

📖 Learn More

Related Article JSON vs YAML vs XML: Complete Data Format Guide →

📖 Learn More

Related Article How to Convert Between YAML & JSON →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service