Preview:
const rgb2hsl = (r,g,b) => {
  const [r1,g1,b1] = [r/255, g/255, b/255];
  const [cmax, cmin] = [Math.max(r1,g1,b1), Math.min(r1,g1,b1)];
    
  const d = (cmax - cmin);

  const L = (cmax + cmin) / 2;
  const S = d == 0 ? 0 : (d / ( 1 - Math.abs(2*L-1)));
  const H = d == 0 ? 0 : 
            cmax == r1 ? (60 * (((g1 - b1) / d) % 6)) : 
            cmax == g1 ? (60 * (((b1 - r1) / d) + 2)) : 
                         (60 * (((r1 - g1) / d) + 4));
  return [H, S, L];
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter