.env Password Escaper
Write a password into a .env line that shell, Node.js dotenv, python-dotenv or docker --env-file read back exactly, quotes and $ included.
Each line is quoted so that the parser reads back exactly your password: shell uses single quotes with '\'' for quotes, Node dotenv picks single, double or backtick quotes, python-dotenv escapes \ and ' inside single quotes, and docker --env-file takes the rest of the line literally (no quotes).
Runs entirely in your browser. Your data is never uploaded.
What is .env Password Escaper?
Passwords with quotes, dollar signs, # or backslashes often break .env files or get changed by variable expansion. This tool writes KEY=value lines that each parser reads back as exactly your password, and warns when a parser cannot represent the value.
How to use .env Password Escaper
- Enter the Variable name, for example DB_PASSWORD.
- Type the password into the Password field.
- Copy the line for your target: shell/POSIX, Node.js dotenv, python-dotenv or docker run --env-file.
- Paste it into your .env file.
Example
Variable DB_PASSWORD, password p@ss'w"rd$1
Shell: DB_PASSWORD='p@ss'\''w"rd$1' Node dotenv: DB_PASSWORD=`p@ss'w"rd$1` python-dotenv: DB_PASSWORD='p@ss\'w"rd$1' docker --env-file: DB_PASSWORD=p@ss'w"rd$1
When to use .env Password Escaper
Use it whenever a secret contains characters other than letters and digits. If you control the secret, a long alphanumeric value avoids escaping issues entirely.
How .env Password Escaper works
Shell: the value is wrapped in single quotes and each ' becomes '\'' (no expansion happens inside single quotes). Node dotenv (v15+): single quotes are literal; if the value contains ', double quotes are used (only \n and \r are interpreted), else backticks; values ending in a backslash or containing all three quote types cannot be represented. python-dotenv: single quotes, with \ and ' escaped as \\ and \'. docker --env-file: no quoting at all; the rest of the line is the value, so newlines are impossible.
Common Use Cases
- Adding a database password with $ and quotes to a .env file
- Preparing secrets for docker run --env-file
- Fixing dotenv values that are cut off at #
- Writing export statements for shell scripts
FAQs
Why not just use double quotes?
Inside double quotes, shells and some dotenv loaders expand $VAR and interpret backslashes, which silently changes the password.
Why is the docker --env-file line unquoted?
docker run --env-file does not process quotes; quotes would become part of the value.
Does Docker Compose use the same rules?
Docker Compose's .env parser has its own interpolation rules, which this tool does not model; check the Compose documentation or use $$ for literal dollar signs there.