Lighten a hex color by a percentage.
Code
Generalconst num = parseInt(hex.replace('#', ''), 16);
const amt = Math.round(2.55 * percent);
const R = Math.min(255, (num >> 16) + amt);
const G = Math.min(255, ((num >> 8) & 0x00FF) + amt);
const B = Math.min(255, (num & 0x0000FF) + amt);
return '#' + [R, G, B].map(x => x.toString(16).padStart(2, '0')).join('');Parameters
The hex color to lighten
Percentage to lighten (0-100)
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).
Is Light Color
Check if a hex color is light (good for determining text color).
Random Hex Color
Generate a random hexadecimal color code for use in CSS or graphics applications.