.yml vs .yaml

Updated

.yml and .yaml are two file extensions for the same format. A parser does not care which one you use. The official recommendation is .yaml, but many popular tools standardized on .yml years ago, so both are everywhere. Here is where the two came from and what each major tool expects.

The short answer

  • Prefer .yaml for new files. It is the extension recommended by the YAML maintainers.
  • Follow the tool's convention when a tool looks for a specific file name.
  • Be consistent within a project. Mixing both is harmless but looks careless.

Why two extensions exist

YAML was created in 2001. At that time, Windows and some other systems still had strong conventions around three-character extensions, so .yml appeared alongside .yaml the same way .htm appeared alongside .html. Once those limits disappeared, the YAML project settled on .yaml as the recommended extension, but by then several influential tools had already shipped with .yml defaults and never changed them.

What popular tools expect

ToolExpected fileNotes
Docker Composecompose.yamlAlso accepts compose.yml, docker-compose.yaml, docker-compose.yml
KubernetesAnykubectl apply -f accepts .yaml, .yml, and .json
GitHub Actions.github/workflows/*.yml or *.yamlBoth discovered automatically
GitLab CI.gitlab-ci.ymlFixed name, .yml
Travis CI.travis.ymlFixed name, .yml
CircleCI.circleci/config.ymlFixed name, .yml
AnsibleAnyCommunity style guide recommends .yml
HelmChart.yaml, values.yamlFixed names, .yaml
OpenAPI / Swaggeropenapi.yamlConvention, either works
Home Assistantconfiguration.yamlFixed name, .yaml
Ruby on Railsconfig/database.ymlFixed names, .yml
pnpmpnpm-lock.yamlFixed name, .yaml

Editor and tooling support

Every mainstream editor associates both extensions with YAML syntax highlighting, and language servers such as the Red Hat YAML extension for VS Code recognize both. Linters like yamllint check both by default. You will not lose any tooling by choosing either one.

Making the switch in a project

  1. Search for hard-coded references: grep -r "\.yml" . across scripts, Dockerfiles, CI config, and documentation.
  2. Rename files with git mv so history is preserved.
  3. Update the references you found and run your CI pipeline.
  4. Validate each renamed file with the YAML validator to make sure nothing was corrupted during the move.

Whichever extension you pick, the content follows the same rules. If you are new to the format, start with YAML vs JSON for an overview of the syntax.

Frequently asked questions

Is there any difference between .yml and .yaml files?

No. Both extensions contain the same YAML format and are parsed identically. The only difference is the file name.

Which extension is official?

.yaml. The YAML FAQ on yaml.org recommends it, and it has been the preferred choice since the days of three-character extension limits ended.

Why do so many projects use .yml?

Habit, mostly. Early tools such as Ruby on Rails, Travis CI, and Docker Compose used .yml, and their conventions spread. Some Windows-era tooling also favored three-character extensions.

Does Docker Compose require docker-compose.yml?

No. Compose v2 searches for compose.yaml, compose.yml, docker-compose.yaml, and docker-compose.yml in that order. compose.yaml is the recommended name.

Can I rename .yml files to .yaml?

Yes, as long as no tool looks for the file by exact name. Check for hard-coded paths in scripts, CI config, and Dockerfiles before renaming.