Last modified: January 24, 2026
This article is written in: 🇺🇸
YAML, or "YAML Ain't Markup Language," is a human-readable data serialization format. It is commonly used for configuration files and data exchange between languages with different data structures. YAML is designed to be readable and concise, with a focus on data readability over markup verbosity.
Data Types: YAML supports scalar types (such as strings, integers, and floats), complex mappings (associative arrays or objects), and sequences (lists or arrays).
Syntax: YAML syntax is designed to be easily readable and writable by humans. It uses indentation to denote structure, allowing for a more natural representation of nested data structures.
: to denote key-value pairs.- at the start of the item in the list.# symbol.Here's a simple example:
employee:
name: John Doe
age: 30
department: Engineering
address:
street: 1234 Main St
city: Anytown
state: CA
zipCode: 12345
skills:
- Java
- C#
- Python
While both YAML and JSON are used for data serialization, YAML is more human-readable, which makes it preferred for configuration files. JSON, being more compact and parsed natively by JavaScript, is often used for web APIs and data interchange.
| Feature | YAML (YAML Ain't Markup Language) | JSON (JavaScript Object Notation) |
| Format | Human-readable, text-based format. | Lightweight, text-based format. |
| Readability | Highly readable due to its minimalistic design and use of indentation. | Readable, though less human-friendly than YAML due to bracket usage. |
| Data Types | Supports complex data types and structures. | Supports basic data types like string, number, array, boolean, and null. |
| Comments | Allows comments. | Does not support comments. |
| Hierarchical Structure | Uses indentation to denote structure, which can be more intuitive. | Uses braces { } and brackets [ ] to denote objects and arrays. |
| Parsing | Requires a YAML parser. | Easily parsed with standard JavaScript functions. |
| File Extension | .yaml or .yml |
.json |
| Verbose | Less verbose than JSON in many cases due to the lack of brackets. | More verbose due to use of brackets and commas. |
| Security | Requires careful parsing due to potential security issues. | Generally secure, but also requires secure parsing practices. |
| Use Cases | Often used for configuration files, data serialization, and in applications where human readability is a priority. | Commonly used in web services, APIs, and settings where a lightweight and easily parsable format is desired. |