What is a .env file?
Environment Variables File · Code and data · Community convention (dotenv) · 2012
A .env file stores configuration as simple KEY=value lines, used to keep secrets and settings (API keys, database URLs) out of source code. It is loaded into a program's environment at startup.
What is a .env file used for?
The .env convention, popularised by the dotenv libraries, lets each developer or deployment set its own values without changing code. Each line is NAME=value; the file is plain text and opens in any editor.
Because .env files hold secrets, they are almost always excluded from version control via .gitignore. Committing one by accident is a common way credentials leak.
What opens a .env file?
The .env format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.
Windows
- VS Code
- Notepad++
- any text editor
macOS
- VS Code
- TextEdit
- any text editor
Linux
- VS Code
- nano
- any text editor
Open a .env file step by step
- Confirm the file really is a .env. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with VS Code or Notepad++.
- On Mac, use VS Code or TextEdit.
- On Linux, try VS Code or nano.
- Still stuck? Search for a dedicated ENV viewer rather than a generic one.
Why can't I open my .env file?
Almost always because no installed app understands ENV. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .env at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
ENV has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
Frequently asked questions
What is a .env file?
A .env file stores configuration as simple KEY=value lines, used to keep secrets and settings (API keys, database URLs) out of source code. It is loaded into a program's environment at startup.
How do I open a .env file?
Any text editor opens it. In some file managers you may need to show hidden files, since names beginning with a dot are hidden by default.
Why is my .env file not being read?
The app must load it (many use a dotenv library), the file must sit where the app looks, and each line must be NAME=value with no spaces around the equals sign.
Should I commit my .env file to Git?
No. It holds secrets. Add .env to .gitignore and share a .env.example with blank values instead.
Related formats
Sources
Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.