Title: [util] Allow `styleText` to take in hex colors · Issue #61543 · nodejs/node · GitHub
Open Graph Title: [util] Allow `styleText` to take in hex colors · Issue #61543 · nodejs/node
X Title: [util] Allow `styleText` to take in hex colors · Issue #61543 · nodejs/node
Description: What is the problem this feature will solve? Many userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in several libraries that existed prior to util....
Open Graph Description: What is the problem this feature will solve? Many userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in sever...
X Description: What is the problem this feature will solve? Many userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in sever...
Opengraph URL: https://github.com/nodejs/node/issues/61543
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[util] Allow `styleText` to take in hex colors","articleBody":"### What is the problem this feature will solve?\n\nMany userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in several libraries that existed prior to [`util.styleText`](https://nodejs.org/api/util.html#utilstyletextformat-text-options). For example:\n\n* [`ansis`](https://github.com/webdiscus/ansis?tab=readme-ov-file#256-colors): supports 256 and truecolor support with fallbacks to base 16 colors\n* [`chalk`](https://github.com/chalk/chalk?tab=readme-ov-file#256-and-truecolor-color-support): has full 256 and truecolor support with fallbacks to terminal-supported levels\n* [`gradient-string`](https://github.com/bokub/gradient-string): dedicated library for terminal gradients (see their ['who uses gradient string'](https://github.com/bokub/gradient-string?tab=readme-ov-file#who-uses-gradient-string) for some pretty examples)\n\nHowever, `util.styleText` only supports the [standard 16 colors](https://nodejs.org/api/util.html#foreground-colors).\n\n### What is the feature you are proposing to solve the problem?\n\nCould `util.styleText` take in hex codes?\n\n```js\nstyleText('#ffcc00', 'Success!');\n```\n\nThey could be detected as anything starting with `#`.\n\n### What alternatives have you considered?\n\nUserland code could stick with raw hex code printing. But that's rather inconvenient and error-prone. Plus, functions like `styleText` respect the `NO_COLOR`, `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.\n\nWas this discussed in the design of `styleText`? I searched around and couldn't find it.","author":{"url":"https://github.com/JoshuaKGoldberg","@type":"Person","name":"JoshuaKGoldberg"},"datePublished":"2026-01-27T12:45:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/61543/node/issues/61543"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4efdfe80-9109-ad92-057d-be3e849ad955 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF84:1EDC91:33500E:454666:6A4D2D84 |
| html-safe-nonce | 7c3a0ec4d1bb2420308837b2be09de84936922aa3546cbd24e4694def6031a5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjg0OjFFREM5MTozMzUwMEU6NDU0NjY2OjZBNEQyRDg0IiwidmlzaXRvcl9pZCI6IjE5Njg1NjQxNDI2ODQ4NDMzOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | db89278a5c64c38d94aecf2b8bd49c04ae7d66bc070905aba8014bb50c96931b |
| hovercard-subject-tag | issue:3860432668 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/61543/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a485c3ee7f9c672067d32f9950efa9f192b0acf6945cb2c015f8b28614459c6/nodejs/node/issues/61543 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a485c3ee7f9c672067d32f9950efa9f192b0acf6945cb2c015f8b28614459c6/nodejs/node/issues/61543 |
| og:image:alt | What is the problem this feature will solve? Many userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in sever... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JoshuaKGoldberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 93f17a978ee60bc4668e1d7b90e6bd2d622261fd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width