YAML(YAML Ain't Markup Language)
YAML 是一种对人友好的数据序列化语言,使用缩进来表示结构。它是 DevOps 工具(Docker Compose、Kubernetes、Ansible、GitHub Actions)配置文件的首选格式,也是 JSON 的超集。
MIME 类型
application/x-yaml
类型
文本
压缩
无损
优点
- + Highly readable — minimal syntax noise
- + Supports comments for inline documentation
- + Native in Docker, Kubernetes, Ansible, and CI/CD systems
- + Superset of JSON — any JSON is valid YAML
缺点
- − Indentation-sensitive — whitespace errors cause silent failures
- − Implicit type coercion can cause bugs ('yes' becomes boolean true)
- − More complex specification than JSON with anchors, tags, and directives
何时使用 .YAML
在配置文件、CI/CD 流水线、容器编排以及任何人工编辑的结构化数据中使用 YAML。
技术细节
YAML 使用缩进(空格,非制表符)表示嵌套,冒号表示键值对,连字符表示列表项。支持锚点(&)和别名(*)进行数据复用、多行字符串和注释。
历史
Clark Evans、Ingy dot Net 和 Oren Ben-Kiki 于 2001 年创建了 YAML。这个递归名称代表「YAML Ain't Markup Language」。YAML 1.2(2009)将规范对齐为 JSON 超集。
从 .YAML 转换
转换为 .YAML
相关格式
相关术语
Learn More
JSON vs YAML vs TOML: Choosing a Configuration Format
Configuration files are the backbone of modern applications. JSON, YAML, and TOML each offer different trade-offs between readability, complexity, and …
How to Format and Validate JSON Data
Malformed JSON causes silent failures in APIs and configuration files. Learn how to format, validate, and debug JSON documents to …
Base64 Encoding: How It Works and When to Use It
Base64 converts binary data into ASCII text, making it safe for transmission through text-based systems. Learn when Base64 is the …
Best Practices for Working with Unix Timestamps
Unix timestamps provide a language-agnostic way to represent points in time, but they come with pitfalls around time zones, precision, …
Troubleshooting JWT Token Issues
JSON Web Tokens are widely used for authentication but can be frustrating to debug. This guide covers common JWT problems …
Hash Functions Compared: MD5, SHA-1, SHA-256, and Beyond
Hash functions are used for file integrity, password storage, and digital signatures. This comparison covers the most common algorithms, their …