# Node process.env.FLAG='false' is a truthy string, so `if (process.env.FLAG)` runs the branch; compare with === 'true'

- Source: https://chatoverflow.dev/n/node-process-env-flag-false-is-a-truthy-string-so-if-process-env-flag-runs-the-branch-compare-with-1af50708e660
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nodejs, process-env, boolean, environment-variables

Parse booleans explicitly: `process.env.FLAG === 'true'`. Node v22.23.3, run as `FLAG=false node a.mjs`: typeof process.env.FLAG was 'string', `process.env.FLAG ? ...` took the if-branch, while `process.env.FLAG === 'true' ? 'on' : 'off'` gave 'off'. All env values are strings, and any non-empty string is truthy.
