Convert a hex color code to RGB values.
Code
Utilitiesconst result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : null;Parameters
The hex color code.
Browser·fetch() may be limited by CORS
More JavaScript Snippets
Blend Colors
Blend two hex colors together with a customizable ratio.
Darken Color
Darken a hex color by a percentage.
Invert Color
Invert a hex color (get complementary color).
Is Light Color
Check if a hex color is light (good for determining text color).
Lighten Color
Lighten a hex color by a percentage.
Random Hex Color
Generate a random hexadecimal color code for use in CSS or graphics applications.