Practical YAML patterns for configs and data.

Data & Parsing

Use this reference when you need a valid YAML structure for config files, CI pipelines, or deployment manifests. The emphasis is on spacing, shape, and common mistakes.

Mappings
app:
  name: coderstool
  env: production

Example: Useful for config files where values are grouped under a parent key.

Gotcha: Indentation is structural. Mixing tabs and spaces will break parsing in many tools.

Lists
services:
  - api
  - worker
  - scheduler

Example: A clean format for ordered values such as service names, hosts, or roles.

Gotcha: Each list item needs the same indentation level under the parent key.

Nested Data

Nest a list of objects

Open tool
users:
  - name: Ada
    role: admin
  - name: Linus
    role: maintainer

Example: Useful for deployment config, CI jobs, or any file that stores repeated structured records.

Gotcha: Child properties must line up under the list item they belong to.

Strings
message: |
  Build finished successfully.
  Deploy starts in five minutes.

Example: Use the pipe style when you want to preserve line breaks in notes, templates, or messages.

Gotcha: Use `|` to keep newlines and `>` to fold them. Pick the one that matches how the receiving tool reads text.

Types
retries: 3
enabled: true

Example: Useful when you want config values to remain typed rather than turn into plain strings.

Gotcha: Some YAML parsers are permissive with scalar types. Quote values when you explicitly need string semantics.



YAML Tutorial | Learn YAML in 10 Minutes

Getting information off the Internet is like taking a drink from a fire hydrant.

Mitchell Kapor

CodersTool Categories