DEV Community

Sakari
Sakari

Posted on

Converting opacity from percentage to hexadecimal in cli

I have been working on my own color theme for the past couple of weeks. As I have been working with colors a lot I realized that I was checking this really useful Hexadecimal color code for transparency gist multiple times per coding session to check what is e.g. 30% opacity in hex (btw it's 4D, I got it memorized!).

Always checking the gist became tiring and over the weekend, I created this nifty npm package to quickly convert any opacity value into hex directly from my cli.

You can install it with

npm install -g @mskri/hex-opacity
Enter fullscreen mode Exit fullscreen mode

Once installed you can then run following command in your cli to get the percentage value in hexadecimal

hex-opacity <opacity value>
Enter fullscreen mode Exit fullscreen mode

For example converting 30% opacity to hexadecimal would be

$ hex-opacity 30
4D
Enter fullscreen mode Exit fullscreen mode

Check out the package at https://www.npmjs.com/package/@mskri/hex-opacity

Top comments (0)