Skip to content
Convert hex to rgb and vice-versa, from the terminal
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
cli.js
package.json
yarn.lock

README.md

convert-color-cli

Convert HEX codes to RGB and vice-versa from the command line.

Install

You can install the package globally to use it anywhere:

npm install -g convert-color-cli # or yarn global add convert-color-cli

Usage

Globally

Convert RGB to HEX. You can pass the three RGB values as separate arguments or you can pass the full rgb(x,x,x) string wrapped in quotes. If doing RGBA, you must wrap in quotes.

$ convert-color 255 154 253
> ff9afd

$ convert-color 'rgb(40, 42, 54)'
> 282a36

$ convert-color 'rgba(40, 42, 54, 75%)'
> 282a36bf

Convert HEX to RGB. The # is optional but if you include it you must wrap the input in quotes. It can also handle HEX codes with alpha values.

$ convert-color ff9afd
> rgb(255, 154, 253)
$ convert-color '#282a36'
> rgb(40, 42, 54)
$ convert-color 282a36bf
> rgba(40, 42, 54, 75%)

Related

This CLI makes heavy use of these excellent modules under the hood:

License

MIT © Mike McBride

You can’t perform that action at this time.