What Is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialisation format popular for configuration files. GitHub Actions workflows, Kubernetes manifests, Docker Compose files, and Ansible playbooks are all written in YAML. It is a superset of JSON — so every JSON file is also valid YAML — but it adds comments, anchors, and cleaner syntax for complex structures.
The One-Line Definition
YAML is a whitespace-sensitive, human-readable data serialisation language defined by the YAML specification. It is commonly used for configuration files and supports rich data types including strings, numbers, booleans, lists, and mappings.
A YAML Example
# GitHub Actions workflow (YAML)
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test
env:
NODE_ENV: testIndentation Rules
Always use spaces, never tabs. YAML parsers reject tab characters for indentation. Two spaces per level is the most common convention. Child keys must be indented further than their parent — inconsistent indentation causes parse errors.
Data Types
hello or "hello"Quotes are optional unless the value contains special characters.
42Plain decimal. Use 0x1F for hex, 0o17 for octal.
3.14 or 1.2e3Scientific notation supported.
true / falseYAML 1.1 also accepted yes/no/on/off; YAML 1.2 only true/false.
null or ~Represents an absent or empty value.
- item1
- item2Block style uses dash + space prefix per item.
key: valueKeys and values separated by colon + space.
| (literal) or > (folded)| preserves newlines. > folds newlines into spaces.
Anchors & Aliases
# Define a reusable block with an anchor defaults: &defaults timeout: 30 retries: 3 # Merge the anchor with << and override one key production: <<: *defaults timeout: 60 # override
YAML vs JSON
# comment · JSON: Not supportedNo (optional) · JSON: Yes, for stringsSignificant (spaces only) · JSON: Cosmetic only&anchor / *alias · JSON: Not supported| and > block scalars · JSON: \n escapes onlyYes (YAML 1.2) · JSON: N/AConfig files · JSON: API payloadsConvert YAML Now
YAML to JSON → · JSON to YAML → — all conversions run in the browser.
Frequently Asked Questions
What are the YAML indentation rules?
Always use spaces, never tabs. Be consistent — two spaces per level is standard. Children must be indented further than their parent. Mismatched indentation causes parse errors.
What is the difference between YAML and JSON?
YAML supports comments, optional quotes, anchors for reuse, and multi-line strings. JSON is stricter and better for APIs. YAML is preferred for config files. YAML 1.2 is a strict superset of JSON.
What are YAML anchors and aliases?
&name marks a block as an anchor. *name inserts a copy (alias) of that block. Use <<: *name to merge a mapping anchor into another mapping.
How do I convert YAML to JSON online?
Paste your YAML into SmartDevBox YAML to JSON tool. It converts and pretty-prints the result instantly, all client-side.