CODE/2023-10-20

YAML Syntax Essentials for Engineers

YAML is a human-readable serialization format commonly used for configuration. Its indentation and scalar rules make it concise, but small formatting mistakes can change the resulting data.

Mappings and lists

yaml_snippet
YAML · 9 lines|
name: example
retries: 3
enabled: true
tags:
- dev
- operations
server:
host: localhost
port: 8080
Use spaces for indentation, not tabs. Members at the same nesting level must align. A list item begins with - , and a mapping generally uses key: value.

Strings and comments

yaml_snippet
YAML · 3 lines|
message: "Hello\nworld"
literal: 'Backslashes are literal here'
# A comment
Quote strings when their content might otherwise be interpreted as another type or syntax. Double-quoted strings support escapes; single-quoted strings use doubled single quotes to represent a quote. Parser versions and schemas may interpret some unquoted scalars differently.

Multiline text

yaml_snippet
YAML · 6 lines|
literal: |
First line
Second line
folded: >
This usually becomes
one line.
| preserves line breaks; > folds many line breaks into spaces. Chomping indicators such as |- control trailing newlines.

Documents, anchors, and tags

--- starts a document and ... can mark its end. Anchors (&name) and aliases (*name) allow reuse within a document. Explicit tags such as !!str can request a type, subject to parser support.
Validate YAML with the parser and schema used by the target application, and use safe loading when parsing untrusted input.
COMPANION ESSAYS / 思想脉络与互照篇目
同卷深读2026-05-22 ·

Installing Python 3 Alongside System Python on CentOS 7

同属「系统工程卷」脉络衍生思考与工程推演推演阅读 →
跨界互照2026-08-22 ·

我的书架:03|金融经管:经济运行、金融体系与企业治理

我的书架:03|金融经管:经济运行、金融体系与企业治理

跨领域对照思辨 · 从「思想随笔」视界互为印证推演阅读 →
RELATED INDEX / 相关阅读索引
柯航hang.ke·© 2014—2026
CC BY-NC 4.0·