Yaml is yet market language for data serialization format properties files are used for representing key and value simple values.

Both are used for configuration files for deployment and application configuration.

For example, Spring boot supports the application.yaml and application.properties file for configuration settings

But there are some differences in yaml and properties extension.

Difference between .yaml and .yml file extension

  • No Maps or lists in a properties file, but yaml has it

yaml and properties extensions support key and values, and Yaml has extra support for Arrays and map types

Let’s have an array of objects in a yaml file.

---
- id: 1
  name: Franc
  roles:
  - admin
  - hr
- id: 2
  name: John
  roles:
  - admin
  - finance

It is difficult to represent in property flat structure. Here is an example for representing an array of objects in a properties file.

id[0]=1
name0=franc
roles00=admin
roles01=hr
id[1]=2
name1=john
roles10=admin
roles11=finance

As you see above, Properties files keys are repeated and readability is not good

  • hierarchical structure vs non-hierarchical structure
profile:
    qa:
        url: http://qa.com
        database: appqa
    prod:
        url: http://prod.com
        database: appprod

The same can be configured in the properties file with a flat structure.

profile.qa.url=http://qa.com
profile.qa.database=appqa
profile.prod.url=http://prod.com
profile.prod.url=appprod
  • Break multiple String

Properties files are supported to break keys and values in multiple lines using escape characters with limited support.

Yaml supports full fledge to break a string into multiple lines

It supports two kinds of syntaxes literal and folder block to split into multiple lines.

We have a string

key: 'Longer string is separated into multiple lines here

here is literal styles using pipe(|) operator
```YAML
key: |
  Longer 
  string 
  is 
  separated 
  into 
  multiple 
  lines 
  here

Folder style syntax to break into multi-lines

key: >
  Longer 
  string 
  is 
  separated 
  into 
  multiple 
  lines 
  here  
  • Popularity

properties syntax uses in a java programming language, but you can use it in other programming languages with external libraries.

Where YAML is mostly used by all popular programming languages

yaml vs properties file extension

yaml properties
Contains key and value pairs Key and values separated by equal or color
Human readable format Easy to read by humans
Supports Integer, Strings, Maps, and Lists Supports primitive types like strings and numbers
Supports hierarchical structure Supports flat and non-hierarchical structure

Conclusion

YAML has more superset features when compared with properties in features like types(List and Map), type safety, and hierarchical structure.

It is always best to choose yaml with wider programming language support.