YAML vs YML: Understanding the File Extensions

Listen to this Post

Featured Image
Both `.yaml` and `.yml` are correct extensions for YAML (YAML Ain’t Markup Language) files. Here’s the breakdown:

  • .yaml → The official and preferred extension, especially in modern documentation.
  • .yml → A shorter version, often used for compatibility with older systems that limit file extensions to three characters.

Example Usage:

 application.yaml (Preferred) 
server: 
port: 8080 
environment: production 
 application.yml (Also valid) 
database: 
url: jdbc:mysql://localhost:3306/mydb 
username: admin 

You Should Know:

1. Validating YAML Files

Use `yamllint` to check syntax errors:

yamllint config.yaml 

2. Converting JSON to YAML

Use Python’s `yaml` module:

python3 -c 'import sys, yaml, json; print(yaml.dump(json.loads(sys.stdin.read())))' < file.json > file.yaml 

3. Parsing YAML in Bash

Install `yq` (YAML processor for CLI):

sudo apt install yq  Debian/Ubuntu 
yq eval '.server.port' config.yaml  Extract a value 

4. Spring Boot YAML Configuration

Spring Boot supports both extensions. Example `application.yml`:

spring: 
datasource: 
url: jdbc:postgresql://localhost:5432/mydb 
username: user 
password: pass 

5. Docker Compose YAML

Docker uses `.yml` by convention:

 docker-compose.yml 
services: 
web: 
image: nginx:latest 
ports: 
- "80:80" 

6. YAML Anchors & Aliases (Advanced)

Reuse configurations with `&` and “:

defaults: &defaults 
adapter: postgres 
host: localhost

development: 
<<: defaults 
database: dev_db 

What Undercode Say:

YAML’s flexibility makes it ideal for configuration files in DevOps, cloud engineering, and containerization. While `.yaml` is the standard, `.yml` remains widely supported. Always validate YAML files before deployment to avoid runtime errors.

Expected Output:

 Sample YAML Output 
metadata: 
author: undercode 
tags: [yaml, devops, configuration] 
tools: 
- yamllint 
- yq 
- jq (for JSON conversion) 

Prediction:

YAML will continue dominating configuration management in cloud-native ecosystems, with stricter linting tools emerging for security-focused validation.

(No URLs were extracted as the original post did not contain relevant links.)

References:

Reported By: Hamza Ullah – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram