YAML Cheatsheet

YAML is a human-friendly data format often used for configuration files. Learn its basics with clear examples and explanations. Perfect for students and beginners.

Basics

YAML stands for “YAML Ain’t Markup Language.” It uses indentation (spaces, not tabs) to represent structure. Data is written as key–value pairs.

name: Alice
age: 25
city: Paris

Indentation

Indentation defines hierarchy. Use **spaces only**, not tabs. Children must be indented more than their parent.

person:
  name: Alice
  age: 25

Lists

Lists are written with dashes (-). Each item appears on a new line with the same indentation.

fruits:
  - apple
  - banana
  - cherry

Dictionaries (Maps)

Dictionaries store key–value pairs. They are like JSON objects, but use colons instead of braces.

person:
  name: Alice
  age: 25

Nested Structures

Lists and dictionaries can be nested inside each other. This is how you build complex structures.

people:
  - name: Alice
    age: 25
  - name: Bob
    age: 30

Comments

Use # for comments. Comments are ignored by the computer but help humans understand the file.

# This is a comment
name: Alice

Multi-line Strings

Use | for multi-line text (preserves line breaks). Use > for folded text (joins into one line).

description: |
  This is line 1
  This is line 2

Anchors & Aliases

Anchors (&) let you reuse content. Aliases (*) refer back to anchors.

defaults: &defaults
  country: France

person:
  name: Alice
  <<: *defaults

How to use this page

  1. Start with basics: key–value pairs and indentation.
  2. Learn lists and dictionaries to represent structured data.
  3. Use comments and multi-line strings for readability and docs.
  4. Practice anchors & aliases to avoid repeating yourself.

🚀 Explore More Free Developer Tools

Don’t stop here! Supercharge your workflow with our other powerful converters & formatters.

💡 New tools are added regularly — bookmark DevUtilsX and stay ahead!

Want to support my work?

Buy me a coffee