Developer Tools5 min read7 March 2026
YAML Explained: Syntax Guide and JSON ↔ YAML Converter
Learn YAML syntax — scalars, sequences, mappings, anchors, and multiline strings. Understand when to use YAML vs JSON and convert between formats instantly.
What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialisation format. It's designed to be clean, minimal, and easy for humans to write and read. YAML is the dominant format for configuration files in the DevOps world:
- Kubernetes manifests (
.yaml) - Docker Compose files (
docker-compose.yml) - GitHub Actions workflows (
.github/workflows/) - Ansible playbooks
- CI/CD configs (CircleCI, Travis CI, GitLab CI)
YAML vs JSON
YAML is a superset of JSON — every valid JSON file is valid YAML. Key differences:
- No curly braces or square brackets needed — YAML uses indentation for structure
- Comments supported — use
#for comments (JSON has none) - Multiline strings built-in — YAML has block scalar syntax
- More human-writable — no need to quote every string key
- Stricter indentation — tabs are not allowed; only spaces
YAML Syntax Basics
# This is a comment
name: Alice
age: 30
active: true
score: 95.5
nothing: null
# Mapping (object)
address:
street: 123 Main St
city: Hyderabad
pin: 500001
# Sequence (array)
tags:
- developer
- python
- kubernetes
Multiline Strings
# Literal block scalar — preserves newlines
description: |
Line one.
Line two.
Line three.
# Folded block scalar — folds newlines to spaces
summary: >
This long text will be
folded into a single line.
Anchors & Aliases (DRY configs)
defaults: &defaults
timeout: 30
retries: 3
production:
<<: *defaults
host: prod.example.com
staging:
<<: *defaults
host: staging.example.com
The & creates an anchor and * references it — perfect for reusing values across a config file.
Common YAML Pitfalls
- Tabs cause parse errors — use spaces only
- Implicit type coercion —
yes,on,trueall become booleantrue; quote them if you need the string - Trailing spaces — can cause unexpected parse failures
- Indentation consistency — each nested level must be indented by the same number of spaces
Using the ToolsPal YAML ↔ JSON Converters
- Paste your YAML or JSON into the input panel
- The converted output appears instantly in the other format
- Upload
.yamlor.ymlfiles directly via drag-and-drop - Adjust indentation (2 or 4 spaces) for the output
Free Online Tool
Try YAML to JSON
Convert YAML configuration files to JSON format.