{"_id":"hex-rgb","_rev":"4081110","name":"hex-rgb","description":"Convert HEX color to RGBA","dist-tags":{"latest":"5.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2025-10-28T01:30:09.000Z","created":"2014-07-27T13:35:05.331Z","5.0.0":"2021-05-03T12:21:33.891Z","4.3.0":"2021-04-07T09:12:28.132Z","4.2.0":"2020-09-06T14:13:34.508Z","4.1.0":"2019-04-15T03:13:57.267Z","4.0.0":"2019-02-10T08:34:09.311Z","3.0.0":"2018-04-03T17:45:44.335Z","2.0.0":"2017-12-30T21:19:56.702Z","1.0.0":"2014-07-27T13:35:05.331Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"versions":{"5.0.0":{"name":"hex-rgb","version":"5.0.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter","css"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.39.1"},"gitHead":"26dbac3f0d7aca87e0a2fb10809b4e16e40b39ff","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@5.0.0","_nodeVersion":"16.0.0","_npmVersion":"7.10.0","dist":{"shasum":"e2c9eb6a37498d66c5a350a221ed4c2c7d1a92d6","size":2583,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_5.0.0_1620044493763_0.2976151084031269"},"_hasShrinkwrap":false,"publish_time":1620044493891,"_cnpm_publish_time":1620044493891,"_cnpmcore_publish_time":"2021-12-16T13:08:37.862Z"},"4.3.0":{"name":"hex-rgb","version":"4.3.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter","css"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"7c0c9f45fb42de20f3d0dba6653340222f7b1923","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@4.3.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"af5e974e83bb2fefe44d55182b004ec818c07776","size":2608,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-4.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-4.3.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_4.3.0_1617786747971_0.35579208073125757"},"_hasShrinkwrap":false,"publish_time":1617786748132,"_cnpm_publish_time":1617786748132,"_cnpmcore_publish_time":"2021-12-16T13:08:38.095Z"},"4.2.0":{"name":"hex-rgb","version":"4.2.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter","css"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"732eeaf7acb9af2bd27e83372800cefc657bbbe0","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@4.2.0","_nodeVersion":"10.22.0","_npmVersion":"6.14.7","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fb377f2e5658fc924f1efa189685922e56ecaf0f","size":2497,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-4.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-4.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_4.2.0_1599401614329_0.10472260637855402"},"_hasShrinkwrap":false,"publish_time":1599401614508,"_cnpm_publish_time":1599401614508,"_cnpmcore_publish_time":"2021-12-16T13:08:38.318Z"},"4.1.0":{"name":"hex-rgb","version":"4.1.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"3194dedec7f4299f275c5aaab98cdb42056a0f98","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@4.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"2d5d3a2943bd40e7dc9b0d5b98903d7d17035967","size":2102,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-4.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_4.1.0_1555298037133_0.8330356132546488"},"_hasShrinkwrap":false,"publish_time":1555298037267,"_cnpm_publish_time":1555298037267,"_cnpmcore_publish_time":"2021-12-16T13:08:38.520Z"},"4.0.0":{"name":"hex-rgb","version":"4.0.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter"],"devDependencies":{"ava":"^1.2.0","xo":"^0.24.0"},"gitHead":"f806870710b42b36652e3c2f49a3b98651c12649","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@4.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"9df2123d4c37fe2600bbba0047fed7c53dffab90","size":1874,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_4.0.0_1549787649223_0.4097497275255597"},"_hasShrinkwrap":false,"publish_time":1549787649311,"_cnpm_publish_time":1549787649311,"_cnpmcore_publish_time":"2021-12-16T13:08:38.711Z"},"3.0.0":{"name":"hex-rgb","version":"3.0.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter"],"devDependencies":{"ava":"*","xo":"*"},"gitHead":"cd19d4d588895b2fe2841709084a6a6a77925a8b","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@3.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"bdff98ce1c18daec8ed87797fe13b02831a9515a","size":1882,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb_3.0.0_1522777544271_0.8687731276546662"},"_hasShrinkwrap":false,"publish_time":1522777544335,"_cnpm_publish_time":1522777544335,"_cnpmcore_publish_time":"2021-12-16T13:08:39.070Z"},"2.0.0":{"name":"hex-rgb","version":"2.0.0","description":"Convert HEX color to RGBA","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/hex-rgb.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["hex","rgb","rgba","color","colour","convert","conversion","converter"],"devDependencies":{"ava":"*","xo":"*"},"gitHead":"8eed60cb5a1beddc2565e19ca770934978955bb6","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","_id":"hex-rgb@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"e7da9ad8398bb8767e925c8a412f5dd0d1504da0","size":1858,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hex-rgb-2.0.0.tgz_1514668795770_0.2835243842564523"},"directories":{},"publish_time":1514668796702,"_hasShrinkwrap":false,"_cnpm_publish_time":1514668796702,"_cnpmcore_publish_time":"2021-12-16T13:08:39.266Z"},"1.0.0":{"name":"hex-rgb","version":"1.0.0","description":"Convert HEX color to RGB","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/hex-rgb"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"node test.js"},"files":["index.js"],"keywords":["hex","rgb","color","colour","convert","conversion","converter"],"devDependencies":{"ava":"0.0.3"},"gitHead":"a46b3139ef5b78b8a9752c53d07c0f23c942f461","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"homepage":"https://github.com/sindresorhus/hex-rgb","_id":"hex-rgb@1.0.0","_shasum":"532275697cb9823e052429b184c6781d46cfdf49","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"532275697cb9823e052429b184c6781d46cfdf49","size":873,"noattachment":false,"key":"/hex-rgb/-/hex-rgb-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hex-rgb/download/hex-rgb-1.0.0.tgz"},"directories":{},"publish_time":1406468105331,"_hasShrinkwrap":false,"_cnpm_publish_time":1406468105331,"_cnpmcore_publish_time":"2021-12-16T13:08:39.475Z"}},"readme":"# hex-rgb\n\n> Convert HEX color to RGBA\n\n## Install\n\n```\n$ npm install hex-rgb\n```\n\n## Usage\n\n```js\nimport hexRgb from 'hex-rgb';\n\nhexRgb('4183c4');\n//=> {red: 65, green: 131, blue: 196, alpha: 1}\n\nhexRgb('#4183c4');\n//=> {red: 65, green: 131, blue: 196, alpha: 1}\n\nhexRgb('#fff');\n//=> {red: 255, green: 255, blue: 255, alpha: 1}\n\nhexRgb('#22222299');\n//=> {red: 34, green: 34, blue: 34, alpha: 0.6}\n\nhexRgb('#0006');\n//=> {red: 0, green: 0, blue: 0, alpha: 0.4}\n\nhexRgb('#cd2222cc');\n//=> {red: 205, green: 34, blue: 34, alpha: 0.8}\n\nhexRgb('#cd2222cc', {format: 'array'});\n//=> [205, 34, 34, 0.8]\n\nhexRgb('#cd2222cc', {format: 'css'});\n//=> 'rgb(205 34 34 / 80%)'\n\nhexRgb('#000', {format: 'css'});\n//=> 'rgb(0 0 0)'\n\nhexRgb('#22222299', {alpha: 1});\n//=> {red: 34, green: 34, blue: 34, alpha: 1}\n\nhexRgb('#fff', {alpha: 0.5});\n//=> {red: 255, green: 255, blue: 255, alpha: 0.5}\n```\n\n## API\n\n### hexRgb(hex, options?)\n\n#### hex\n\nType: `string`\n\nThe color in HEX format. Leading `#` is optional.\n\n#### options\n\nType: `object`\n\n##### format\n\nType: `string`\\\nValues: `'object' | 'array' | 'css'`\\\nDefaults: `'object'`\n\nThe RGB output format.\n\nNote that when using the `css` format, the value of the alpha channel is rounded to two decimal places.\n\n##### alpha\n\nType: `number`\n\nSet the alpha of the color.\n\nThis overrides any existing alpha component in the Hex color string. For example, the `99` in `#22222299`.\n\nThe number must be in the range 0 to 1.\n\n## Related\n\nSee [rgb-hex](https://github.com/sindresorhus/rgb-hex) for the inverse.\n","_attachments":{},"homepage":"https://github.com/sindresorhus/hex-rgb#readme","bugs":{"url":"https://github.com/sindresorhus/hex-rgb/issues"},"license":"MIT"}