>_
smartdevbox
Try SmartDevBox free — no sign-up91+ tools · 100% client-side · no account required
Glossary

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: test

Indentation 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

Stringhello or "hello"
Quotes are optional unless the value contains special characters.
Integer42
Plain decimal. Use 0x1F for hex, 0o17 for octal.
Float3.14 or 1.2e3
Scientific notation supported.
Booleantrue / false
YAML 1.1 also accepted yes/no/on/off; YAML 1.2 only true/false.
Nullnull or ~
Represents an absent or empty value.
Sequence (array)- item1 - item2
Block style uses dash + space prefix per item.
Mapping (object)key: value
Keys and values separated by colon + space.
Multi-line string| (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

CommentsYAML: # comment ·  JSON: Not supported
Quotes requiredYAML: No (optional) ·  JSON: Yes, for strings
IndentationYAML: Significant (spaces only) ·  JSON: Cosmetic only
Anchors / aliasesYAML: &anchor / *alias ·  JSON: Not supported
Multi-line stringsYAML: | and > block scalars ·  JSON: \n escapes only
JSON supersetYAML: Yes (YAML 1.2) ·  JSON: N/A
Common useYAML: Config files ·  JSON: API payloads

Convert 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.

YAML to JSONConvert a YAML document to JSON in the browser.
JSON to YAMLConvert a JSON document to YAML in the browser.
What Is JSON?JSON is the wire-format sibling to YAML — stricter, more portable.