Check if a hex color is light (good for determining text color).
Code
Generalconst num = parseInt(hex.replace('#', ''), 16);
const r = (num >> 16) & 255, g = (num >> 8) & 255, b = num & 255;
return (r * 0.299 + g * 0.587 + b * 0.114) > 186;Parameters
Hex color to check
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.
Hex to RGB
Convert a hex color code to RGB values.
Invert Color
Invert a hex color (get complementary 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.