🧰Daily Toolbox
← すべてのガイド
yaml

YAML Basics for Config Files

2026-08-29 · 4分で読了
[AdSense placeholder — 広告枠]

# Demystifying YAML: A Beginner’s Guide to Configuration Files

If you are navigating the world of modern software development, you have likely encountered YAML. Short for "YAML Ain't Markup Language" (a recursive acronym), YAML has become the undisputed gold standard for writing configuration files. Whether you are spinning up a Docker container, orchestrating a Kubernetes cluster, or setting up a Continuous Integration pipeline, YAML is everywhere. Its widespread adoption boils down to one simple fact: it is incredibly easy for humans to read and write.

The Core Principle: Key-Value Pairs and Indentation

At its heart, YAML is a collection of key-value pairs. Unlike JSON or XML, which rely heavily on brackets and braces, YAML uses a minimalist syntax. The structure and hierarchy of your data are defined entirely by indentation.

Here is the most important rule in YAML: you must use spaces, never tabs. Mixing tabs and spaces will break your file. Typically, two spaces per indentation level is the standard.

```yaml
server:
host: localhost
port: 8080
```

In this example, `host` and `port` belong to the `server` mapping. This clean structure allows developers to understand the configuration at a glance.

Organizing Data: Lists and Dictionaries

To handle more complex configurations, YAML relies on two primary data structures: lists (arrays) and dictionaries (mappings).

Lists allow you to define a sequence of items. They are denoted by a hyphen followed by a space (`- `):

```yaml
environment_variables:
- DATABASE_URL
- API_KEY
- SECRET_TOKEN
```

Dictionaries are simply nested key-value pairs under a parent key. You can combine lists and dictionaries to create rich, detailed configurations:

```yaml
services:
web:
image: nginx:latest
ports:
- "80:80"
- "443:443"
database:
image: postgres:14
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: securepassword123
```

Essential Features: Comments, Strings, and Data Types

YAML is designed to be as frictionless as possible, offering several features that make configuration management a breeze

#yaml#config#dev

紹介した無料ツールを試す

data」ツールを開く →