YAML

What Is YAML?

YAML is a human-readable data serialization format for representing structured data. Its readability makes it well suited to configuration files.

Basic Syntax

Indentation

Use spaces, not tabs, for indentation in YAML. Two or four spaces are commonly used. As in Python, indentation expresses the data hierarchy.

Two-space indentation (recommended):

spring:
  profiles:
    default: local
  application:
    name: devkuma-api

Four-space indentation:

spring:
    profiles:
        default: local
    application:
        name: devkuma-api

Defining Data (Map)

Use a colon (:) to define scalar key-value pairs.

spring:
  profiles:
    default: local
  application:
    name: devkuma-api

Defining Arrays

Use a hyphen (-) to list array items.

project:
  name: devkuma
  languages:
    - Java
    - html

Comments

Use a hash sign (#) for comments.

# Full-line comment
project:
  name: devkuma # Inline comment
  languages:
    - Java
    - html

Boolean Values

Boolean values can be written as true and false, as well as yes and no.

show-sql: yes
init: no
devkuma: True
araikuma: TRUE
manual: false

Numbers

Integers and floating-point values without quotation marks (") are interpreted as numbers.

# number
version: 1.4

# string
version: "1.4"

References