TR

Home / Guides / What Is YAML? Indentation Rules, Differences from JSON, and Common Mistakes

What Is YAML? Indentation Rules, Differences from JSON, and Common Mistakes

Updated: October 13, 2026 · AracMerkezi

▶ Open YAML to JSON Converter

YAML is a data format designed to be easy for humans to read. It is used in Docker Compose, Kubernetes, GitHub Actions, and many configuration files. It has fewer symbols than JSON; the structure is determined by indentation.

Basic syntax

name: Ayşe

age: 30

active: true

tags:

- php

- js

address:

city: Malatya

Indentation rules

  1. Use only spaces; do not use tab characters. YAML does not accept tabs in indentation.
  2. Items at the same level must start with the same number of spaces; the common choice is 2 spaces.
  3. One level too much or too little indentation can change the meaning entirely or cause an error.

Differences from JSON

FeatureYAMLJSON
ReadabilityHighMedium
CommentsYes (#)No
StructureIndentationBrackets
Multiline textSupportedOnly with \n
Trailing comma errorNoneYes

YAML 1.2 is nearly a superset of JSON; that is, most valid JSON can also be read as YAML. In practice, however, tools implement different YAML versions.

Common mistakes

YAML ↔ JSON conversion

Using JSON to send a configuration to an API and YAML to edit it is a common approach. The YAML to JSON Converter converts common YAML structures (nested objects, lists, text, numbers, booleans) to JSON. For the reverse direction, there is the JSON to YAML Converter tool. To validate the result, you can use the JSON Formatter.

Converters do not cover every YAML feature. Advanced structures such as anchors and aliases (& and *), multi-document files, and custom tags may not be supported. For important configuration files, also verify the conversion result with your own tooling.

Security note

In some languages, loading YAML from an untrusted source with the general-purpose loader can lead to code execution; use “safe load” functions. Avoid storing passwords and keys as plain text in YAML files.

Multiline text

There are two notations for long text:

description: |

First line

Second line

The pipe (|) preserves line breaks; the greater-than sign (>) folds lines into a single line. This feature does not exist in JSON and makes configuration files readable.

Example: configuration conversion

If, under server:, it says port: 8080 and debug: false, the JSON equivalent is {"server": {"port": 8080, "debug": false}}. Note that the port is written without quotes: YAML reads this as a number; if you write "8080", it becomes text. This difference causes an error if it does not match the type your application expects.

The validation habit

Before saving a YAML file, running it through a validator or converting it to JSON catches indentation errors. If the conversion fails, look at the line of the error; most of the time a list's indentation is missing. In Kubernetes or CI files, a single wrong indentation can make the entire deployment fail.

When YAML, when JSON?

YAML for configurations that people will edit; JSON is safer for data exchange between programs. A need for comments favors YAML, while a need for a strict, unambiguous structure favors JSON.

Frequently asked questions

Can tabs be used in YAML?

No; only spaces are used for indentation, and tab characters cause an error.

Why does the value “NO” become false in YAML?

In older YAML versions, yes/no and on/off are converted to booleans; write such text in quotes.

What is the difference between YAML and JSON?

YAML uses indentation and supports comments; JSON builds structure with brackets and does not support comments.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.