Skip to content
LangStop

Glossary

Keyboard Shortcuts

ActionShortcut
Toggle SidebarCtrl+B
Save TabCtrl+S
Close TabAlt+W
Switch to Tab 1Alt+Shift+1
Switch to Tab 2Alt+Shift+2
Switch to Tab 3Alt+Shift+3
Switch to Tab 4Alt+Shift+4
Switch to Tab 5Alt+Shift+5
Switch to Tab 6Alt+Shift+6
Switch to Tab 7Alt+Shift+7
Switch to Tab 8Alt+Shift+8
Switch to Tab 9Alt+Shift+9

Settings

Appearance

Customize the look and feel of the editor and interface.

Editor Theme

The font size used in the code editor.

14px

Space between lines in the editor.

1.6×

Changes apply instantly

What is YAML? — YAML Ain't Markup Language Explained

Definition

YAML (YAML Ain't Markup Language) is a human-readable data serialization standard used for configuration files, data exchange, and structured data storage. Unlike markup languages (like HTML or XML), YAML focuses on data rather than document structure. Its indentation-based syntax makes it cleaner and more readable than JSON or XML, especially for configuration files that humans edit regularly.


YAML Syntax Basics

YAML relies on indentation (spaces, not tabs) to define structure:

# This is a YAML comment
key: value
nested:
  child_key: child_value
  list:
    - item1
    - item2
    - item3

Key Rules

  1. Use spaces for indentation (typically 2 spaces)
  2. Do not use tabs
  3. Indentation level defines nesting depth
  4. Comments start with #
  5. Quotes are optional for strings (unlike JSON)

YAML Data Types

Type Example Notes
String hello, "hello", 'hello' Quotes optional
Integer 42, -7, 0xFF Decimal, hex, octal
Float 3.14, 1.0e+6, inf Scientific notation supported
Boolean true, false, yes, no Multiple representations
Null null, ~, (empty) Various null representations
Date 2024-01-15 ISO 8601 format
Timestamp 2024-01-15T14:30:00Z ISO 8601 with time
Sequence [1, 2, 3] or block list Ordered list
Mapping {key: value} or block mapping Key-value pairs

Indentation Rules

Indentation is YAML's most important — and most error-prone — feature:

# Two spaces per level
person:
  name: Alice
  address:
    city: New York
    zip: "10001"
  hobbies:
    - reading
    - hiking

Rules:

  • Same-level items must have the same indentation
  • Children are indented deeper than their parent
  • Tabs are not allowed as indentation
  • Consistent indentation is critical

Anchors and Aliases

YAML supports anchors (&) and aliases (*) to reuse content:

defaults: &defaults
  adapter: postgres
  host: localhost
 
development:
  database: myapp_dev
  <<: *defaults
 
production:
  database: myapp_prod
  <<: *defaults
  host: prod-db.example.com

This is equivalent to:

development:
  adapter: postgres
  host: localhost
  database: myapp_dev
 
production:
  adapter: postgres
  host: prod-db.example.com
  database: myapp_prod

Multi-line Strings

YAML offers several ways to handle multi-line strings:

# Literal block (preserves line breaks)
description: |
  This is a multi-line
  string that preserves
  line breaks.
 
# Folded block (wraps lines)
summary: >
  This long text will be
  folded into a single
  line when parsed.
 
# Double-quoted (escape sequences)
message: "Hello\nWorld\n"

JSON Compatibility

YAML 1.2 is a superset of JSON — any valid JSON file is also a valid YAML file:

{
  "name": "Alice",
  "age": 30
}

This is valid YAML because JSON syntax is a subset of YAML 1.2.


Common Use Cases

DevOps and Infrastructure

  • Kubernetes — Pods, Deployments, Services (all YAML)
  • Docker Compose — Multi-container definitions
  • Ansible — Playbooks and inventory
  • CI/CD — GitHub Actions, GitLab CI, CircleCI

Application Configuration

  • Ruby on Rails — database.yml, application.yml
  • Symfony — PHP framework configs
  • Logstash/Filebeat — Data pipeline configs

API Specifications

  • OpenAPI (Swagger) — API documentation
  • Serverless Framework — Cloud function configs

LangStop YAML Tools

Related Tools

Try these complementary developer tools: