About the .env File Generator
The .env File Generator turns a simple list of variable names and values into a properly formatted .env file, plus a .env.example template you can safely commit. It is meant for developers setting up a new project or documenting the configuration an app needs.
How it works
Each row becomes one KEY=value line. Keys are converted to uppercase, and any character that is not a letter, digit, or underscore is replaced with an underscore, so "app name" becomes APP_NAME. Rows with an empty key are skipped.
A value is wrapped in double quotes if it contains whitespace, or always if Always quote values is ticked; any double quotes inside the value are escaped with a backslash. The .env.example output uses the same keys, each followed by an equals sign and nothing else. The Hide values button only masks the value fields on screen; it does not change the output.
How to use
- 1
Edit or replace the sample rows (DATABASE_URL, API_KEY, PORT) with your own keys and values.
- 2
Click Add Variable for more rows, or the - button to remove one.
- 3
Tick Always quote values if you want every value in double quotes.
- 4
Click Copy .env and Copy .env.example, and save each into a file of that name in your project root.
Worked examples
The sample variables
A typical web app with a database, an API key, and a port.
A key with spaces and a value with spaces
Entering an app name the way you would say it.
The key is normalized to uppercase with an underscore, and the value is quoted because it contains a space.
Frequently asked questions
Should I commit my .env file to version control?+
No. A .env file with real secrets should stay out of Git. Commit the .env.example this tool generates instead, which lists the variable names without values.
What format do environment variables use in a .env file?+
One KEY=value pair per line, with no spaces around the equals sign. Values with spaces are wrapped in double quotes.
Why did my key change?+
Keys are converted to uppercase, and characters other than letters, digits, and underscores become underscores. So my-key becomes MY_KEY, which most tools expect.
When are values quoted?+
Automatically when the value contains a space, tab, or other whitespace, or always when Always quote values is ticked. Double quotes inside a value are escaped as \".
Does Hide values remove values from the output?+
No. It only masks the value input fields on screen. The .env output still contains the values; use the .env.example output if you need a version without them.