Color Converter

Color Converter

Convert colors between HEX, RGB and HSL with a live preview.

Ready.

The same color can be written several ways — HEX in CSS, RGB in code, HSL when you want to nudge brightness or saturation — and different tools, platforms and teams each prefer a different one. This HEX to RGB converter takes any HEX, RGB or HSL value and returns the other two formats, with a live preview so you can see the exact color you are working with.

No uploads, no sign-up, and no waiting — simply paste a value and all formats are updated in real time, ready to copy into your stylesheet or design tool of choice.

How to Use the Color Converter

  1. Type or paste a color into the Color value box — HEX (#FF5733), RGB (rgb(255, 87, 51)) or HSL (hsl(11, 100%, 60%)). The # is optional, and 3-digit shorthand such as #f53 works too.
    color value box
  2. Or click the color square beside the box to pick a shade visually — the field fills itself in.
    color picker square
  3. The Preview panel shows the color at full size so you can check it before you use it.
    live color preview
  4. The other two formats convert as you type — there is no separate convert button.
    hex rgb hsl outputs
  5. Click Copy beside HEX, RGB or HSL to put that value on your clipboard.
    copy format button
  6. Change the input at any time and every field updates instantly.
    fields update instantly

Everything runs in your browser, so conversions are instant and your color values are never sent anywhere.

What Is a Color Format?

When You’d Use This

Worked Example

Input: #FF5733 → RGB: rgb(255, 87, 51) → HSL: hsl(11, 100%, 60%). All three are the same orange-red, which is what converting a HEX color to RGB actually does — it renames the value rather than altering it. FF is 255 (full red), 57 is 87 (moderate green) and 33 is 51 (low blue) — exactly the RGB values. HSL describes that same color as a hue angle with percentages instead of channel intensities.

HSL is rounded to whole degrees and percentages, so converting #FF5733 to HSL and straight back returns #FF5833 — one step off, and normal.

Color Conversion in Code

JavaScript — HEX to RGB

function hexToRgb(hex) {
  const r = parseInt(hex.slice(1, 3), 16);
  const g = parseInt(hex.slice(3, 5), 16);
  const b = parseInt(hex.slice(5, 7), 16);
  return { r, g, b };
}
hexToRgb("#FF5733"); // { r: 255, g: 87, b: 51 }

JavaScript — RGB to HEX

function rgbToHex(r, g, b) {
  return "#" + [r, g, b]
.map(x => x.toString(16).padStart(2, "0"))
.join("");
}
rgbToHex(255, 87, 51); // "#ff5733"

Do’s and Don’ts

Do

Don’t

Common Mistakes

Good to Know

FAQ

What is the difference between HEX and RGB?

They carry the same color information — HEX as a six-digit hexadecimal code, RGB as three numbers from 0 to 255 for the red, green and blue channels. Browsers and CSS accept both, so to convert HEX to RGB you are only rewriting the same value, not changing the colour it describes.

Why use HSL instead of HEX or RGB?

HSL splits a color into hue, saturation and lightness, which makes it far easier to build a lighter, darker or more muted version without recalculating every RGB channel.

Does converting a color change how it looks?

No. HEX, RGB and HSL are three ways of writing the same color, so it looks identical in all three.

Can I convert screen colors to print?

Not exactly. Print uses CMYK, a narrower color model, so some bright screen values cannot be reproduced in ink and need adjusting.

Why does a HEX code need a #?

The # marks the characters after it as a hexadecimal color rather than plain text. CSS and most design tools require it, although this converter will accept a value without it.

How many colors can HEX and RGB describe?

Standard 24-bit HEX and RGB cover about 16.7 million colors — 256 possible values on each of the red, green and blue channels.