.env File Syntax
How envapt parses .env files, including keys, quoting, escapes, multi-line values, and inline comments.
envapt ships its own .env parser with zero dependencies. This page is the grammar it accepts. For which files load, see Configuration; for ${VAR} interpolation, see Templates.
Keys and values
Each line is KEY=value. An optional export prefix is allowed, so a file you also source in a shell works unchanged.
APP_NAME=envapt
export PORT=3000A key is letters, digits, and underscores, and does not start with a digit. Leading whitespace around the key and = is ignored. An empty value resolves to an empty string.
EMPTY=Comments
A line whose first non-whitespace character is # is a comment. An inline # after an unquoted value also starts a comment, but only when preceded by whitespace, so a # inside a value is kept.
# full-line comment
HOST=localhost # inline comment, stripped
COLOR=#ff0000 # kept: the # has no leading space before itCOLOR reads as #ff0000.
Quoting
A value can be wrapped in single quotes, double quotes, or backticks. The quote style decides escape handling, not whether multi-line works (all three support it).
| Quote | Escapes | Use it for |
|---|---|---|
"double" | decodes \n \r \t \\ \" | values where you want \n to become a real newline |
'single' | none, fully literal | values that should stay exactly as written |
`backtick` | none, fully literal | same as single, when the value contains ' |
Only double quotes interpret escapes. Inside single quotes or backticks, \n stays as the two characters
backslash-n, it does not become a newline. Use double quotes when you want escape decoding.
Multi-line values
A quoted value runs across as many lines as you need: one opening quote, the content, one closing quote. This is how you store a certificate or private key.
TLS_CERT="-----BEGIN CERTIFICATE-----
MIIBkTCB+wIJAKHH...
...more base64...
-----END CERTIFICATE-----"You read it back as one string, newlines intact:
const cert = .('TLS_CERT');With double quotes you can also keep it on one line and write \n between segments; envapt decodes them. With single quotes or backticks the line breaks must be real (a literal \n stays literal).
Unescaped inner quotes
Like dotenv, envapt matches a quoted value to the rightmost matching quote on the value, so unescaped inner quotes are tolerated.
JSON="{"name":"envapt","port":3000}"JSON above round-trips to {"name":"envapt","port":3000} without escaping the inner quotes. Pair it with the
Json converter to parse it.
The parser stores values literally; it does not expand ${VAR} here. That interpolation runs when you read a value,
covered in Templates.
Using secret stores
Fetch secrets from 1Password, Vault, Doppler, AWS Secrets Manager, and others, then read them typed. envapt does not fetch secrets, it reads what you bind.
Compatibility
Runtime support, engine versions, module formats, the portable and node builds, and how decorators behave across runtimes.