YAML stands for Ain’t Markup Language, representing a new data format for serialization, similar to file formats like like toml or ini .

These files contain text data arranged in a hierarchical structure.

It supports Scalar types (Integer, strings, float, Boolean, Time) and collection types (array, list).

The series of posts in this course are designed to provide you with the fundamentals of YAML, along with examples to facilitate your learning.

YAML introduction

YAML stands for Ain’t Markup Language , and new data format for serialization language like toml or ini file format.

These files contain text data arranged in a hierarchical structure.

It supports Scalar types (Integer, strings, float, Boolean, Time) and collection types (array, list).

This course series of posts helps you to get the basics with examples for learning.

Important points:

  • It is case sensitive, key: value and Key: value are different
  • file extension is .yaml
  • Tabs are not allowed,
  • Some editors allow spaces

Advantages

  • Lightweight
  • It is very easy and simple to represent the complex mapping
  • Friendly readable and writable
  • Simple to modify with any text editor
  • Suitable for configuration settings
  • Support for major programming languages

Disadvantages

  • It is a new format introduced recently, and a learning curve exists.
  • Not much popular other than XML and JSON
  • It is very complex to represent configuration in the hierarchy of data

What is the file extension

yaml files are created with the extension .yaml or .yml. You can use any IDE or text editor to open this file.

All the popular IDEs support the yaml file extension and also provide plugins to validate the yaml file content.

What is the YAML media type?

Media or MIME types are present in request headers with Content-Type and Accept during data transfer between systems.

According to IANA , there is no official MIME type for YAML document content.

However, it can be represented using MIME types such as text/yaml, text/x-yaml, or application/x-yaml.

During the transfer of YAML data between a client and a server, implementation vendors include MIME type settings specified in requests and responses over the internet. The commonly used MIME format type for YAML is text/yaml.

The Content-Type and Accept headers in a request object are specified in this format. For example:

Content-Type and accept headers in a request object are specified with this format.

Following is the mime type for these documents

content-type: text/yaml

or
accepts: text/yaml

The other possible options include

  • text/yaml
  • text/yml
  • text/x-yaml
  • application/yaml
  • application/yml

The choice among these options depends on the browser and the supported programming language. For instance, Chrome accepts application/yaml.

How do you open yaml files?

Open these files with ease in your favorite text editor, whether it’s Visual Studio, Atom, Sublime Text, Notepad++, or Intelli IDEA on Windows, UNIX, or MAC OS.

While basic editors offer simple reading and writing capabilities without format and validation, IDEs take it a step further with plugins that provide:

Automatic or manual code formatting Syntax highlighting for a colorful coding experience Inline rendering of content in HTML view Some plugins even offer convenient export options to PDF and other documents.

Current Yaml Version

The current YAML specification version is 1.2.2.

Here is a list of versions:

Following is listi of versions

Parameter  Description  
1.0Initial version, released in 2004
1.12005
1.22009
1.2.2October 2021

Where are YAML usecases?

yaml is a configuration files that can be used in variety of tools and programming languages.

Following are some of the usecases for yaml file configuration

  • settings for applications that contains configurations for different environments. For example, QA environment contains a single yaml file for configurations of a infrastrcuture service such as REDIS URL, database details, etc. Production environment contains a different yaml file for different details of same services.
  • Docker: docker-compose.yml is a file used for deploying containers and vms
  • kubernets: kubernets are used for microservices that contains different pod service configuraiton and deployment settings.
  • Ansible: This tool uses yaml for defining ansible playbooks