env.dev

The Complete .env File Syntax Reference

Definitive reference for .env file syntax: quoting rules, comments, multiline values, variable expansion, and differences across Node.js, Python, Ruby, Go, and Docker Compose.

Last updated:

Loading…

Frequently Asked Questions

Can .env files have comments?

Yes. Lines starting with # are treated as comments in all major dotenv implementations. Inline comments (KEY=value # comment) are supported by some libraries (Python, Ruby) but not all (Node.js dotenv). Avoid inline comments for maximum portability.

Do I need to quote values in .env files?

Unquoted values work for simple strings without spaces or special characters. Use double quotes for values with spaces, newlines (\n), or variable expansion ($VAR). Use single quotes for literal strings where no expansion should occur.

Does .env support multiline values?

Yes, in double quotes. Use \n for newline characters or span multiple lines by keeping the opening and closing quotes. Exact support varies by implementation — Node.js dotenv supports both approaches.

Was this helpful?

Stay up to date

Get notified about new guides, tools, and cheatsheets.