File Extension File Extension Guide

What is a YAML File?Data

A guide to the .yaml extension, a human-readable data file. What a YAML file holds, how its indentation-based layout works, why the .yaml and .yml extensions both exist, and how to open, edit and convert one.

YAML Data 📖 Human-Readable ⚙️ Config Files ✏️ Plain Text
.YAML

YAML Data File

Type:Data serialization
Extension:.yaml / .yml
Format:Plain text
Structure:Indentation
Edit In:Any text editor

📖 What is a YAML File?

A YAML file is a plain-text file that holds structured information in a layout people can read at a glance. It is used mostly to store settings and configuration, and its whole design goal is to be easy on the eye, so in place of the braces and quotation marks common to other data formats, it relies on plain indentation to signal how the pieces fit together.

The name is a small joke that developers enjoy. The letters expand to "YAML Ain't Markup Language", a tongue-in-cheek label announcing that its job is carrying data, not marking up documents the way HTML does. Open one in any text editor and you will usually understand the gist straight away, because a YAML file reads almost like a tidy list of labels and values, with indentation doing the work of showing what belongs inside what.

You will meet YAML files most often as the settings behind software and automated tasks. Tools that build, test and deploy code lean on them heavily, and if you have configured almost anything modern in development you have probably edited a .yaml file, perhaps without thinking much about the format itself. What makes it worth understanding is that a small slip in spacing can change the meaning, so a little knowledge of how YAML is laid out goes a long way toward editing one confidently.

Key Characteristics

  • Plain text, editable in any editor
  • Indentation-based, no brackets needed
  • Human-readable by design
  • Two extensions, .yaml and .yml, same format

Good to Know

  • YAML means YAML Ain't Markup Language
  • Mostly used for settings and config
  • Spacing matters, tabs are not allowed
  • Related to JSON, and converts to it cleanly
💡 Why it matters: A YAML file stores settings in a way built for humans to read and edit. Its indentation is not just for looks, it defines the structure, which is why careful spacing is the key to working with one.

⚡ Quick Facts

File Extension.yaml (also .yml)
Stands ForYAML Ain't Markup Language
What It IsHuman-readable data file
FormatPlain text
StructureDefined by indentation
First Proposed2001
Recommended Ext.yaml (official)
MIME Typeapplication/yaml

🔤 .yaml vs .yml

The first thing that puzzles people about YAML is why the same format turns up with two different extensions, .yaml and .yml. The short answer is reassuring. They are exactly the same thing, and every program that reads YAML happily accepts either one.

The two spellings are a leftover from computing history. When YAML appeared in the early 2000s, many systems still limited file extensions to three letters, a holdover from older Windows and DOS days, so the trimmed .yml caught on out of necessity. Once that limit fell away, the fuller .yaml became the tidier choice, and the official YAML site has recommended .yaml as the preferred spelling since 2006. Today the pick is mostly a matter of habit and community. Some ecosystems lean toward .yml, notably Ruby on Rails and Docker Compose, while others favour .yaml, such as Kubernetes and many newer tools. Neither is more correct in any way that affects how the file works.

For a new file the sensible default is .yaml, since it matches the official recommendation and spells out the format clearly. The one piece of advice worth heeding is to avoid renaming a pile of existing .yml files just to be consistent, because automated build scripts often refer to files by their exact name, and a mass rename can quietly break them. In practice the wise rule is simple. Follow whatever the surrounding project already uses, and reach for .yaml when you are starting fresh.

Aspect.yaml.yml
FormatYAMLYAML (identical)
Official recommendationPreferredAccepted
OriginFull, descriptive nameOld 3-letter limit
Common inKubernetes, newer toolsRails, Docker Compose
Best forNew filesExisting conventions
💡 The short version: .yaml and .yml are the same format read by the same parsers. Use .yaml for new files, keep to whatever an existing project already uses, and do not bulk-rename old .yml files.

✏️ YAML Syntax Basics

Most of YAML comes down to three simple ideas, and once they click a YAML file stops looking like code and starts looking like a neatly organised note.

The first idea is the pair. You write a label, a colon, a space, then a value, so name: Ada reads exactly as it looks. The second idea is the list, where each item sits on its own line behind a dash and a space, giving a clean column of entries. The third idea is nesting, and this is where indentation earns its keep. By pushing lines further to the right with spaces, you show that they belong inside the line above, building a tree of information without a single bracket. Importantly the spacing must be spaces, never tabs, because YAML forbids tab characters for indentation, and two spaces per level is the common habit. Values themselves can be text, numbers, true or false, or left empty, and YAML is usually clever enough to tell which is which.

A small YAML file

# a mapping of key and value pairs
name: Ada Lovelace
active: true
age: 36

# a nested block, shown by indentation
address:
  city: London
  country: England

# a list, one item per dash
skills:
  - mathematics
  - writing
  - computing

Read that top to bottom and it barely needs explaining, which is the entire point of YAML. The labels sit on the left, their values on the right, and the indentation quietly shows that the city and country belong to the address while the three skills form a list of their own.

Indentation builds the structure server: host: alpha.example.com port: 8080 settings: timeout: 30 retries: 3 tags: - web - prod further right means further inside

📝 Multi-Line Text and Comments

Two everyday touches make YAML pleasant to work with, and both turn up constantly once you start reading real files.

The first is the comment. Anything after a hash symbol on a line is ignored by the software, so you can leave notes for yourself and others right beside the settings they explain, which is a big part of why YAML files feel so approachable. The second is a tidy way to hold blocks of text that run over several lines. A vertical bar tells YAML to keep the text exactly as written, line breaks and all, which suits things like a message or a script, while a greater-than sign folds the lines together into one flowing paragraph, handy for a long sentence you would rather wrap neatly in the file. Both let you store sizeable chunks of text without wrestling with quotes or escape characters.

Comments and multi-line text

# the bar keeps every line break
message: |
  Dear reader,
  Thank you for your note.

# the arrow folds lines into one
summary: >
  This long sentence will be
  joined into a single line
  when the file is read.

🔗 Anchors and Reuse

One feature sets YAML apart from simpler formats and often surprises newcomers, the ability to write something once and reuse it elsewhere in the same file.

YAML lets you tag a value or a block with an anchor, marked by an ampersand, and then point back to it later with an alias, marked by an asterisk. Wherever the alias appears, YAML behaves as though you had copied the anchored content into that spot. The benefit is that a setting shared across several places lives in exactly one location, so changing it once updates every use, and the file stays shorter and less error-prone. You tend to see this in larger configuration files where the same block of options would otherwise be repeated many times. It is not something every YAML file needs, but when you spot an ampersand and an asterisk, this reuse is what they mean.

Define once with an anchor, reuse with an alias

# the & anchor names a block
defaults: &defaults
  timeout: 30
  retries: 3

server_a:
  <<: *defaults
  host: alpha.example.com

server_b:
  <<: *defaults
  host: beta.example.com

Here both servers pull in the same defaults without repeating them, so a single edit to the timeout would apply to each one.

📑 Many Documents in One File

A single .yaml file can hold more than one separate document, which is a neat trick worth recognising when you meet it.

Three dashes on their own line act as a divider, marking the start of a new document within the same file, and an optional three dots can signal the end of one. Everything between the markers is treated as an independent piece, so a program reading the file works through each document in turn. This is genuinely useful when several related but distinct sets of settings naturally belong together, letting one file carry them all while keeping each cleanly separated. If you open a YAML file and notice lines of three dashes scattered through it, you are looking at several documents stored side by side rather than one long one.

Two documents separated by three dashes

name: first document
role: web server
---
name: second document
role: database

⚠️ Common YAML Mistakes

Because YAML puts so much meaning into spacing and plain words, a handful of small mistakes catch almost everyone at some point, and knowing them in advance saves a lot of head-scratching.

The most frequent trip-up is using a tab to indent instead of spaces. On screen a tab can look just like spaces, yet the format refuses it outright, so a single stray tab triggers a baffling error, and the cure is to have your editor type spaces instead. Inconsistent indentation is close behind, since lines that should line up but do not will change the structure in ways you did not intend. Another classic surprise is that certain plain words are read as true or false, so an unquoted value like no or off can quietly become a boolean rather than the text you meant, which famously bites people whose data includes the country code for Norway. The safe habit is to wrap any such value in quotes so it stays as text. Forgetting the space after a colon is another small one, since name:Ada is not the same as name: Ada to a parser. None of these are hard to avoid once you know them, and a quick pass through a YAML validator will catch them before they cause trouble.

⚠️ Watch the spacing: Indent with spaces never tabs, keep each level lined up, put a space after every colon, and quote words like "no", "yes" or "off" when you mean them as text rather than true or false.

🔢 YAML Data Types

One of the conveniences of YAML is that it works out what kind of value you have written, so a bare number is read as a number and the word true is read as a yes-or-no value without you saying so. This cleverness is handy most of the time, but it is also the source of the surprises worth knowing about.

The everyday types are text, whole numbers, decimals, true-or-false values and empty values. You write them plainly and YAML reads them the obvious way, so quantity followed by 42 becomes a number while a name followed by a word stays as text. An empty value can be written as null, as a tilde, or simply left blank, all meaning the same nothing. Dates are recognised too, so a value that looks like a calendar date is treated as one. The catch is that this guessing can misfire, and the fix is always the same, wrap the value in quotes to force it to stay as text. That is how you keep a version number like 1.0 or a postcode with a leading zero from being turned into something you did not intend.

How YAML reads a value, and the quoting trap Auto-detected count: 42to number active: trueto boolean nick: nullto empty name: Adato text The trap country: no read as false, not "no" country: "no" quotes keep it as text Quote any value that looks like a number, a true-or-false word or a date
You writeYAML reads it as
name: AliceText (string)
count: 10Whole number (integer)
ratio: 0.75Decimal (float)
active: trueTrue or false (boolean)
nickname: nullEmpty (null)
born: 2000-05-20Date
zip: "07030"Text, quotes force it

Types, and quoting to keep text as text

title: Ada Lovelace      # text
count: 42               # number
active: true            # true or false
nickname: null          # empty, same as ~ or blank

# quote when a value should stay text
version: "1.0"          # not the number 1
zip: "07030"            # keeps the leading zero

💬 Single vs Double Quotes

When you do need quotes, YAML gives you two kinds and they behave a little differently, which trips people up until they see the rule.

Single quotes keep the text exactly as typed, treating everything inside as literal characters, which makes them ideal for things like file paths or text that itself contains backslashes. Double quotes are cleverer, letting you use escape codes such as a backslash-n for a new line or a backslash-t for a tab, so you reach for them when you actually want those special effects. As a rule of thumb, prefer single quotes for plain literal text and switch to double quotes only when you need an escape sequence. You genuinely need quotes of some kind whenever a value would otherwise be misread, so quote anything that looks like a number but should stay text, anything that reads as true, false or null when you mean the word, and any value carrying a colon followed by a space, since that pattern would otherwise look like a new key.

💡 Quick rule: Use single quotes for literal text, double quotes when you need escape codes like a new line, and quote any value that looks like a number, a true-false word or a date but should be read as plain text.

📂 How to Open a YAML File

Opening a YAML file could hardly be simpler, because it is ordinary text underneath, so anything that can show text can show a YAML file.

On any computer you can open one in the built-in editor, whether that is Notepad on Windows or TextEdit on a Mac, and see its contents straight away. For anything beyond a quick peek, a proper code editor is far nicer, and the free VS Code is a popular pick because, with a YAML add-on, it colours the different parts, lines up the indentation and flags mistakes as you type, which is a real help given how much spacing matters. If you only want to inspect a file without installing anything, a web-based viewer such as the one from Univik displays a YAML file neatly in the browser. Whichever you choose, remember that the indentation is meaningful, so it pays to use an editor that shows spaces clearly rather than one that might silently swap in tabs.

1

A quick look

Read it instantly in a basic editor such as Notepad or TextEdit.

2

To edit properly

Use VS Code with a YAML add-on for colour and error checks.

3

In a browser

View a YAML file online with nothing to install.

🔄 How to Convert a YAML File

YAML and JSON are close cousins that hold the same kinds of information in different clothing, so converting between them is a common and painless task.

The two formats map onto each other almost perfectly, which is why so many tools accept both. You might turn YAML into JSON when a program or an interface expects JSON, or turn JSON into YAML to make a dense file friendlier to read and edit. Most programming languages can do the swap in a couple of lines, and for a one-off job an online converter like the one Univik provides changes YAML to JSON and back in the browser without any setup. The result carries the same data, just arranged in the other style, so nothing meaningful is lost in the trip. It is worth a quick check afterwards that the converted file still reads the way you expect, since the two formats handle a few edge cases slightly differently, but for everyday data the round trip is smooth.

🔒 Is YAML Safe?

A YAML file is just text and holds no program of its own, so reading one to a person is perfectly safe. The care needed is on the software side, when a program loads a YAML file automatically, and it is worth understanding because it is a genuine security point rather than a scare.

YAML has an advanced feature that lets a file ask for special object types, and in several languages a carelessly loaded file can turn that feature into running unwanted code on the machine doing the loading. The danger only appears when a program uses the fully powered loading function on a file from a source it does not trust. The safe habit, followed as standard by careful developers, is to use the restricted loading option instead, which sticks to the plain types like text, numbers and lists and ignores the risky part entirely. In Python this is the well-known difference between the plain load call and the safe one, and other languages have their own equivalent. For anyone simply opening and reading a YAML file there is nothing to worry about, and for anyone loading one in code the rule is short, treat files from unknown sources with caution and always use the safe loader.

⚠️ For developers: When a program reads a YAML file, use the safe loading option, such as safe_load in Python, especially for files from sources you do not fully trust. It ignores the advanced tag feature that could otherwise run unwanted code.

❓ Frequently Asked Questions

A YAML file is a plain-text file that stores structured information, such as settings and configuration, in a way that is easy for people to read. Rather than using brackets and quotes like some other data formats, it uses simple indentation to show how pieces of information relate to one another. The name stands for YAML Ain't Markup Language, a light-hearted way of saying it is meant for holding data rather than marking up documents. You will find YAML files behind a great deal of modern software, especially tools that build, test and deploy code, and because they are just text you can open and edit one in any text editor.

Both are correct, and they are the same format. Every program that reads YAML accepts either extension, and the contents follow identical rules. The two spellings exist for historical reasons, because early systems limited extensions to three letters, so the shorter .yml became common before the fuller .yaml took over. The official YAML site recommends .yaml, so it is the better choice for a new file, but plenty of established projects still use .yml and there is nothing wrong with that. The practical advice is to match whatever a project already uses and to prefer .yaml when starting something fresh.

Spacing matters because YAML uses indentation to define structure, so the amount a line is pushed to the right decides what it belongs to. Move a line in or out and you change its meaning, which is very different from formats that use brackets to mark structure explicitly. This is why a small spacing slip can cause an error or a surprising result. The two rules that keep you safe are to indent with spaces rather than tabs, since YAML does not allow tabs for indentation, and to keep the indentation consistent so lines that belong at the same level line up exactly. A good editor that shows spaces clearly makes this easy to get right.

No, tab characters are not permitted for indentation in YAML, and slipping one in is among the most frequent causes of a YAML error. Tabs and spaces can look the same on screen, which makes the problem confusing, since the file appears correctly lined up yet still fails to parse. The fix is to use spaces instead, and most editors can be set to insert spaces automatically when you press the tab key, often with two spaces per level as the usual convention. If a YAML file is throwing an error you cannot explain, a hidden tab is one of the first things worth checking.

YAML and JSON hold the same kinds of structured data but present it differently, and each has its strengths. JSON uses braces, brackets and quotes, which makes it precise and easy for machines to handle but busier for a person to read. YAML uses indentation and far fewer symbols, which makes it gentler on the eye and pleasant to edit by hand, and it also allows comments, which JSON does not. Because the two map onto each other so closely, converting between them is straightforward, and many tools accept both. In short, YAML tends to win where humans do the editing, while JSON is common where data is passed between programs.

Opening a YAML file is easy because it is plain text. On any computer you can open one in the built-in editor, such as Notepad on Windows or TextEdit on a Mac, to read it straight away. For editing it properly, a code editor like the free VS Code is much better, especially with a YAML add-on that colours the parts, lines up the indentation and points out mistakes as you type. If you just want to look at a file without installing anything, an online YAML viewer will show it neatly in your browser. Whichever you use, it helps to pick an editor that displays spaces clearly, since the indentation carries meaning.

Converting YAML to JSON is simple because the two formats represent the same structure. Most programming languages can do it in a couple of lines using a built-in or freely available library, reading the YAML and writing out JSON. For a quick one-off conversion you can use an online converter that changes YAML to JSON, and back again, right in your browser with nothing to install. The converted file holds the same data, just written in the other style, so nothing meaningful is lost. It is still worth a quick look at the result, because the two formats treat a few small details differently, but for ordinary data the conversion is clean and reliable.

YAML handles the everyday kinds of value you would expect, and works out which is which from how you write them. Plain text is a string, a bare number is read as a whole number or a decimal, the words true and false give a yes-or-no value, and an empty value can be written as null, as a tilde, or simply left blank. Values that look like a calendar date are recognised as dates too. Because YAML guesses the type from the look of the value, you sometimes need to step in with quotes, for example to keep a version number or a postcode with a leading zero as text rather than letting it become a number. That single habit, quoting anything that should stay as text, avoids almost all type surprises.

Most of the time you do not need quotes at all, since plain text reads fine on its own. You need them when a value would otherwise be misread, which happens in a few clear cases. Quote a value that looks like a number but should stay as text, such as a version or a code with a leading zero. Quote a word like true, false, yes, no or null when you mean it as plain text rather than a yes-or-no or empty value. And quote any value containing a colon followed by a space, because that pattern would otherwise look like the start of a new key. As for which quote to use, single quotes keep the text exactly as written, while double quotes let you include escape codes like a new line, so reach for single quotes by default and double quotes only when you need those special characters.

This is a famous YAML quirk often called the Norway problem. In older YAML, the words yes, no, on and off were all treated as yes-or-no values, so an unquoted no was read as false rather than the text "no". The classic bite is a list of country codes that includes NO for Norway, which quietly turns into false and breaks the data. The current version of YAML narrowed the official yes-or-no words down to just true and false, but many tools still follow the older behaviour, so the safe habit is to quote any such word when you mean it as text. Writing the country code as "no" in quotes keeps it as the two letters you intended, and the same trick protects any value that might be mistaken for a yes-or-no.

Because a small spacing slip can break a YAML file, it is worth validating one before relying on it, and there are several easy ways. The quickest is an online YAML validator, where you paste the file and it points out any errors right away. In an editor like VS Code, a YAML add-on flags mistakes as you type, underlining a stray tab or a misaligned line before it causes trouble. On the command line, a dedicated checker called yamllint reviews a file and reports both errors and untidy style, and most programming languages can also parse a file to confirm it is valid. Whichever you pick, running a quick check is the surest way to catch the indentation and quoting slips that cause most YAML problems.

Opening a YAML file to read it is completely safe, because it is plain text and holds no program of its own. The care needed is on the software side, when a program loads a YAML file automatically. YAML has an advanced feature for requesting special object types, and in some languages a carelessly loaded file from an untrusted source could use it to run unwanted code. The standard protection, which careful developers follow as a matter of course, is to use a restricted loading option that handles only the plain types and ignores the risky feature, such as the safe loading call in Python. So for simply viewing or editing a file there is nothing to fear, and for loading one in code the rule is to be cautious with files from unknown sources and always use the safe loader.

YAML is used mainly to store settings and configuration in a form that people can read and edit comfortably. You will find it behind a great deal of modern development tooling, describing how software should be built, tested and deployed. It is the usual choice for container and deployment tools such as Docker Compose and Kubernetes, for automation tools like Ansible, and for the workflow files that run automated tasks on code repositories. Beyond configuration, YAML is handy any time structured data needs to be both machine-readable and pleasant for a human to work with, which is why it turns up in so many places where a person edits the file by hand. Its readable, indentation-based style is what makes it such a comfortable fit for these jobs.

📝 Summary

A YAML file is a human-readable, plain-text data file marked by the .yaml extension, whose name stands for YAML Ain't Markup Language. It stores structured information, most often settings and configuration, using indentation rather than brackets to show how data relates, which is what makes it so easy to read and edit. The .yaml and .yml extensions are the same format read by the same parsers, with .yaml the officially recommended spelling since 2006 and .yml a leftover from the days of three-letter extension limits, so the guidance is to use .yaml for new files while keeping to whatever an existing project already uses. Writing YAML comes down to a few ideas, key and value pairs joined by a colon and a space, lists where each item follows a dash, and nesting shown by indenting with spaces, never tabs, at a consistent two spaces per level. Beyond the basics, comments after a hash symbol let you annotate a file, a vertical bar or greater-than sign holds blocks of text across several lines, anchors and aliases let you write a value once and reuse it, and three dashes divide several documents within a single file. The usual pitfalls are spacing mistakes and a few plain words like no or off being read as true or false, both avoided by careful indentation and by quoting text that might be mistaken for something else. Because a YAML file is ordinary text it opens in any editor, though a code editor with a YAML add-on makes editing far easier, and since YAML and JSON describe the same kind of data, converting between the two is quick and lossless for everyday content.