Chuyển tới nội dung chính
Z

What is YAML?

YAML (YAML Ain't Markup Language) is a human-friendly, indentation-based data serialization format used mainly for configuration files. It represents the same data as JSON — scalars, lists and mappings — but with cleaner syntax, comments and multi-line strings, making it popular in CI/CD, Docker and Kubernetes.

YAML uses indentation (spaces, never tabs) to show structure instead of brackets. Mappings are key: value, lists use -, and it supports comments (#), multi-line strings and anchors/references for reuse. Because YAML is a superset of JSON, any JSON is valid YAML.

Its readability makes it the default for human-edited configuration — GitHub Actions, Docker Compose, Kubernetes manifests — where comments and clean diffs matter.

YAML tools

Câu hỏi thường gặp

Vì sao có lúc chuỗi được đặt trong dấu ngoặc kép, có lúc lại không?

js-yaml chỉ đặt dấu ngoặc kép cho các chuỗi có thể bị parse nhầm sang kiểu dữ liệu khác (số, boolean, ngày tháng) hoặc chứa ký tự đặc biệt. Không dùng dấu ngoặc kép được ưu tiên vì giúp dễ đọc hơn.

Công cụ có giữ nguyên thứ tự key không?

Có, theo mặc định — thứ tự của object JSON được giữ nguyên. Bật “Sort keys” để có đầu ra theo thứ tự bảng chữ cái.

Công cụ có xử lý được cấu trúc lồng nhau rất sâu không?

js-yaml không có giới hạn cố định, nhưng các cấu trúc lồng quá sâu (>100 cấp) có thể gặp giới hạn đệ quy của engine JS.