.env to Shell Exports
Turn a .env file into export lines: strip export and quotes, escape what a double-quoted shell string needs, and refuse an invalid name.
What the .env to Shell Exports does
The line is split at the first =, so a value may contain = freely. A leading export is removed, matching a file written by docker env or a shell history, and a surrounding pair of single or double quotes is stripped because it was the file's quoting, not the value's.
The value is then re-quoted once: \, $, backtick and " are escaped inside the double quotes, so $HOME stays a literal dollar sign instead of expanding.
This produces shell text, not a shell. A multi-line value is not supported, because a .env line is one line. Comments inside a quoted value are kept as text; a # after an unquoted value is kept too, because .env has no inline-comment rule every tool agrees on.
How to use it
Paste the file into the .env file box, or press Run with the example already there.
Read the Shell exports below: comments are gone and each variable is one export line.
Check a Shell exports value containing $ — it is escaped, so sourcing the output keeps the literal text instead of expanding a variable.
Worked example
Input:
A=1
export B="two words"
# a comment
C=va$lue
Output:
export A="1"
export B="two words"
export C="va\$lue"
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
One `export NAME="value"` per .env line, with the quoting your shell needs and comments dropped.
A name that is not a shell variable — starting with a digit, or carrying a dash — is refused by name, because `export 1BAD=x` is a syntax error and the file would not load.
What it does, and what it does not
The line is split at the first `=`, so a value may contain `=` freely. A leading `export ` is removed, matching a file written by `docker env` or a shell history, and a surrounding pair of single or double quotes is stripped because it was the file's quoting, not the value's.
The value is then re-quoted once: `\`, `$`, backtick and `"` are escaped inside the double quotes, so `$HOME` stays a literal dollar sign instead of expanding.
This produces shell text, not a shell. A multi-line value is not supported, because a .env line is one line. Comments inside a quoted value are kept as text; a `#` after an unquoted value is kept too, because .env has no inline-comment rule every tool agrees on.
How to use .env to Shell Exports
Paste the file into the .env file box, or press Run with the example already there.
Read the Shell exports below: comments are gone and each variable is one export line.
Check a Shell exports value containing `$` — it is escaped, so sourcing the output keeps the literal text instead of expanding a variable.
What to Expect
Best for
- Sourcing a .env file in a shell
- Checking a name that would break `export`
Not ideal for
- A multi-line secret, which .env cannot hold anyway
- Escaping for a language other than POSIX shell
What this tool keeps
- Values containing = or spaces
- A literal $ as a literal $
What may need cleanup
- A shell that does not accept export needs `NAME=value` instead
- An inline comment after a value is kept as text
Common errors
- The page refuses it: "1BAD" is not a shell variable name
Example use cases
- Loading a .env file into a local shell
- Converting a Docker env file for a script
Sample input
.env file: A=1 …
Sample output
Shell exports: export A="1" …
Who this is for
- Developers running a service locally
- Anyone writing a small deployment script
Frequently asked questions
Why escape the dollar sign?
The value is data from a file. Escaping $ keeps it literal when the output is sourced, which is what the file said; an expanding $HOME would silently change the value.
Are quotes stripped?
One surrounding pair is, because it belonged to the file's syntax. The value is then re-quoted for the shell with its own escapes.
What about an inline comment?
It stays part of the value. .env files have no inline-comment rule that every tool agrees on, and dropping text the user wrote would change the secret.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.