Post

YML vs YAML: Which File Extension Should You Use?

Both .yml and .yaml work identically—learn why both exist and which to choose for your projects.

YML vs YAML: Which File Extension Should You Use?

Both .yml and .yaml extensions work identically. Parsers treat them the same way with no functional difference.

Why Two Extensions Exist

The .yml extension is a legacy artifact from DOS and early Windows systems that enforced a three-character limit on file extensions (like .doc, .txt, .exe). Since “YAML” has four letters, it was shortened to .yml to meet this constraint.

Modern operating systems removed this restriction decades ago, allowing the full .yaml extension.

Official Standard vs Real-World Usage

Official recommendation: Use .yaml per the YAML FAQ and specifications.

Common patterns in tools:

  • GitHub Actions, Docker Compose: Both work, but .yml appears frequently (docker-compose.yml)
  • Kubernetes: Primarily uses .yaml for manifests
  • Ansible: Community often defaults to .yml

Best Practice: Consistency

1
2
3
4
5
6
7
8
# Good: Consistent within project
config.yaml
deployment.yaml
service.yaml

# Bad: Mixed extensions
config.yml
deployment.yaml  # Avoid mixing

Recommendation

For new projects:

  • Use .yaml to align with the official standard
  • Stick to one extension throughout your project

For existing projects:

  • Match whatever extension is already in use
  • Don’t mix .yml and .yaml in the same directory

Both extensions work perfectly—consistency matters more than the choice itself.

☕ Support My Work

If you found this post helpful and want to support more content like this, you can buy me a coffee!

Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏

This post is licensed under CC BY 4.0 by the author.