⇄ JSON to YAML Converter Online
Convert JSON to YAML and YAML to JSON instantly online. Supports nested objects, arrays, and all data types. Free, no signup.
Paste your JSON on the left, select JSON → YAML, and get clean YAML output on the right. Works with any valid JSON including deeply nested structures, arrays, nulls, and booleans. Also converts YAML back to JSON.
How to Use
Paste your data
Paste your JSON, YAML, XML, or CSV content into the input area and select the source format.
Choose target format
Select the output format from the To dropdown. All bidirectional conversions are supported.
Convert and copy
Click Convert. The result appears on the right. Click Copy to use it in your project.
Frequently Asked Questions
Complete Guide: JSON ↔ YAML Converter
JSON and YAML are the two dominant formats for configuration files, API data exchange, and infrastructure-as-code definitions. While JSON is the native format of JavaScript and universally parseable, YAML was designed specifically for human authoring — it is less verbose, supports inline comments, and handles multiline strings naturally. This guide explores both formats, their differences, and the gotchas you need to watch for when converting between them.
Why YAML Over JSON?
YAML offers several ergonomic advantages over JSON:
- Comments: YAML supports inline comments with
#. JSON has no comment syntax, which makes it difficult to document configuration files. - No trailing comma issues: JSON famously rejects trailing commas, causing parse errors when you add or remove the last item in a list. YAML has no such rule.
- Multiline strings: YAML's literal block scalar (
|) preserves newlines, and the folded scalar (>) folds newlines to spaces — both far cleaner than JSON's escaped\ncharacters. - Anchors and aliases: YAML lets you define reusable nodes and reference them, reducing repetition.
YAML Gotchas: The Surprising Parsing Rules
YAML's flexibility comes with parsing rules that regularly surprise developers:
- Boolean explosion: The values
on,off,yes,no,true,false,TRUE,FALSEare all parsed as booleans in YAML 1.1 (used by PyYAML and many tools). If your config key needs the literal string "yes", you must quote it:"yes". - Octal integers: A bare number like
0777is parsed as octal (511 decimal) in YAML 1.1. File permission values in configs need quoting. - Bare strings: Unquoted strings that resemble other types (dates, numbers, booleans) will be coerced.
2024-01-15becomes a Date object in some parsers. - Indentation sensitivity: YAML uses indentation (spaces only — no tabs) to define structure. Inconsistent indentation causes cryptic parse errors.
YAML Anchors and Aliases
Anchors (&name) mark a node for reuse. Aliases (*name) reference that node later, inserting a copy. The <<: *name merge key extends a map with all keys from the anchor:
defaults: &defaults
adapter: postgres
encoding: utf8
development:
<<: *defaults
database: myapp_dev
test:
<<: *defaults
database: myapp_test
Real-World Usage: Kubernetes and GitHub Actions
Kubernetes configuration manifests are written entirely in YAML. A deployment spec can span hundreds of lines, and anchors help avoid repetition across environments. GitHub Actions workflows are YAML files stored in .github/workflows/. The YAML boolean gotcha is especially relevant here — action inputs that expect string values of "true" or "false" must be carefully quoted to avoid being parsed as actual booleans.
JavaScript: js-yaml Library
The js-yaml npm package is the standard YAML parser and serializer for Node.js:
import yaml from 'js-yaml';
// Parse YAML to JS object
const obj = yaml.load(yamlString);
// Serialize JS object to YAML
const yamlOutput = yaml.dump(obj, { indent: 2 });
Python: PyYAML safe_load vs load
PyYAML's yaml.load() can execute arbitrary Python objects if the input contains special YAML tags — a serious security risk when loading untrusted input. Always use yaml.safe_load(), which restricts parsing to standard YAML types only. The difference matters most when processing user-supplied YAML in web applications or CI pipelines.
For formatting and validating JSON before or after conversion, use the JSON Formatter. To compare two JSON documents for differences, try JSON Diff.