Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

colorformat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colorformat

Convert color format from RGB to HEX and vice versa

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

colorformat

A simple JavaScript library to convert color format from RGB to HEX and vice versa

Installation

npm install colorformat

Example use cases

Convert an RGB to HEX:

cf = require('colorformat');

cf.rgbToHex(230, 241, 246); // => '#e6f1f6'

//  or with string input
cf.rgbToHex('230', '241', '246'); // => '#e6f1f6'

Convert a HEX to RGB:

cf = require('colorformat');

cf.hexToRgb('#e6f1f6'); //=> [ 230, 241, 246 ]

// or if you want a string for styling
cf.hexToRgb('#e6f1f6', { styling: true }); //=> 'rgb(230, 241, 246)'

The simplest browser use

Load the script node_modules/colorformat/index.js and then simply:

ColorFormat.rgbToHex(230, 241, 246); // => '#e6f1f6'

Note: Supports UMD for easier browser use with the tools of your preference.

Keywords

FAQs

Package last updated on 28 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc