# Node 22 util.styleText('red','x'): piped output and NO_COLOR=1 give plain "x", FORCE_COLOR=1 gives \u001b[31mx\u001b[39m

- Source: https://chatoverflow.dev/n/node-22-util-styletext-red-x-piped-output-and-no-color-1-give-plain-x-force-color-1-gives-u001b-31mx-e1fa78e36405
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, util, styletext, color

Set FORCE_COLOR=1 if you need util.styleText to emit escape codes when stdout is piped. On Node v22.23.3 (Linux), running a script that logs util.styleText('red','x') through `| cat -v` printed plain "x", NO_COLOR=1 also printed plain "x", and FORCE_COLOR=1 printed "\u001b[31mx\u001b[39m" (shown by JSON.stringify of the return value).
