. It is used to transfer data between applications and services which have different data structures. YAML is a data serialization language Originally YAML meant Yet Another Markup Language. However, it was later repurposed for YAML Ain’t Markup Language to emphasize its data-oriented features. YAML was designed to be useful and friendly while . It uses Unicode printable characters, some of which provide structural information and the rest contain the data. working with data It has clear formatting which makes it human-readable, easy to use, and is easily implemented. YAML and allows the data to be represented in a meaningful way. For example, indentation is used for structure, key-value pairs are separated by colons, and dashes are used to create bullet lists. Hence the format appears clearer and can be easily understood. minimizes the number of structural characters Let us take an example and compare it with JSON and XML:- YAML Employees: - id: 4 employeename: Ryan employeetitle: Marketing Manager JSON { : [ { : , : , : } ] } "Employees" "id" 4 "employeename" "Ryan" "employeetitle" "Marketing Manager" XML 4 Ryan Marketing Manager <?xml version="1.0" encoding="UTF-8"?> < > Employees < > id </ > id < > employeename </ > employeename < > employeetitle </ > employeetitle </ > Employees You can see that YAML and is easier to read. It is the cleanest format of all three. does not use any special characters YAML matches the native data structures of agile methodology. The data structures can all be adequately represented with three basic primitives: mappings (hashes/dictionaries) sequences (arrays/lists) scalars strings/numbers) YAML leverages these to form a complete language for serializing any native data structure. Most programming languages can use YAML for data serialization, including agile languages such as Perl, Python, PHP, Ruby, and JavaScript. Common use cases include writing configuration files, log files, and data sharing. Basic Syntax YAML is case-sensitive. YAML file extensions are .yaml , .yml Data structures are defined using line separations and whitespace indentations. Tabs are not allowed in YAML. Unquoted numerals are considered as integers or floating-point values. Numerals Integers, octal, or hexadecimal values can be specified as: id: 4 octalexample: 012345 hexaexample: 0x12d4 Floating-point values can be fixed and exponential. weight: 55.5 exp: 12.3015e+05 Strings String data types are usually not included in quotes but you can use double or single quotes. firstemployeename: “Ryan” secondemployeename: ‘Ryan’ thirdemployeename: Ryan - You can specify multiline strings in two ways:- Multiline strings Pipe character (|) is used to preserve line breaks. multilineString: | this is a multiline string this is the second line this is the third line The fold character or greater-than sign ( >) folds the text such that it all appears in one line. multilineString: > this is a single line string but is written in this format for clarity Comments Comments start with a hash sign (#). Multiline comments are not supported. For multiline comments, you have to put # at the start of each line. # Write your comment here Key-value pairs The basic building blocks of yaml files are key-value pairs. These are represented in the form key: value. The colon followed by a space. must be Employees: id: 4 employeename: Ryan employeetitle: Marketing Manage This can also be specified inline by using curly braces {} and separating each entry by a comma. Employees: {id: 4 , employeename: Ryan, employeetitle: Marketing Manager} Objects You can group key-value pairs in objects. Leading spaces have to be same for each attribute in an object This is a valid format:- Employees: id: 4 employeename: Ryan employeetitle: Marketing Manager In the example given below, you can see that the attribute is not indented correctly. Below example is an YAML format. employeename invalid Employees: id: 4 employeename: Ryan employeetitle: Marketing Manager Lists List members are specified with a leading hyphen (-). Each entry is on a new line. List of simple data types Employees: - Ryan - Jack Lists can also be written in square brackets. The entries are comma-separated. Employees: [Ryan, Jack] -You can also specify lists of objects in yaml. List of objects Employees: - id: 4 employeename: Ryan employeetitle: Marketing Manager - id: 5 employeename: Jack employeetitle: Product Manager Boolean Booleans can have values True/true/TRUE and False/false/FALSE Employees: - id: 4 employeename: Ryan employeetitle: Marketing Manager onleave: True - id: 5 employeename: Jack employeetitle: Product Manager onleave: False YAML supports in a stream. multiple documents Three hyphens(—) are used to specify the beginning of a new YAML document. You can optionally use three periods (…) to mark the end of a document. --- Employees: - id: 4 employeename: Ryan employeetitle: Marketing Manager ... --- Departments: - id: 1 departmentname: Marketing ... Conclusion YAML, a superset of JSON, is a powerful yet user-friendly language. It is popular for its minimalism and simplicity, and useful for programming needs such as configuration files, Internet messaging, object persistence, and data sharing. For further reading please refer to YAML Ain’t Markup Language (YAML™) Version 1.2 3rd Edition