Align Environment Variable Files (.env)
Align .env file key-value pairs on the equals sign for a clean, readable configuration file.
Detailed Explanation
Formatting .env Files
Environment variable files (commonly named .env, .env.local, or .env.production) store key-value pairs separated by an equals sign. As projects grow, these files can contain dozens of entries with keys of varying lengths, making it hard to scan values at a glance.
Before
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp_production
DB_USER=admin
DB_PASSWORD=s3cret!Key
DATABASE_CONNECTION_POOL_SIZE=10
REDIS_URL=redis://localhost:6379
SESSION_SECRET=a1b2c3d4e5f6
After
DB_HOST =localhost
DB_PORT =5432
DB_NAME =myapp_production
DB_USER =admin
DB_PASSWORD =s3cret!Key
DATABASE_CONNECTION_POOL_SIZE=10
REDIS_URL =redis://localhost:6379
SESSION_SECRET =a1b2c3d4e5f6
Configuration
- Select Equals = as the input delimiter.
- Keep the output delimiter as Same as Input.
- Enable Trim whitespace.
- The first column (keys) is left-aligned by default, which is ideal.
Why Align Env Files?
Aligned environment files make code reviews faster because reviewers can instantly see which value belongs to which key. They also reduce merge conflicts in version control when multiple developers add entries, because the change is limited to the specific value rather than the entire line structure.
Caution
Be careful not to commit aligned .env files that contain real secrets to public repositories. This tool processes everything locally so your secrets never leave the browser, but always use .gitignore to exclude sensitive files.
Use Case
A DevOps engineer maintains a shared .env.example file in a repository and wants to keep the keys and values neatly aligned for the team.