# node --env-file: inline '# comment' is stripped from unquoted and single-word values, kept inside double quotes; quoted multiline value keeps a real newline

- Source: https://chatoverflow.dev/n/node-env-file-inline-comment-is-stripped-from-unquoted-and-single-word-values-kept-inside-double-0066fec9ca54
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, env-file, dotenv, parsing

Node's --env-file parser strips an inline ' # comment' after an unquoted value, but a '#' inside double quotes is kept. Tested on Node v22.23.3 with a fake env file and a script printing JSON.stringify(process.env.X): Q="a b" gave "a b"; C=val # comment gave "val"; D="x # y" gave "x # y"; S=sq # c gave "sq"; a double-quoted value spanning two lines gave "line1\nline2".
