Skip to content
siter.io home

RGB to HEX converter

Type or paste channel values and get hex, HSL and CSS, plus the score against black and white. It runs on your own machine, so nothing is uploaded.

#663399

  • HEX #663399
  • RGB rgb(102, 51, 153)
  • HSL hsl(270, 50%, 40%)
  • CSS #663399
  • 102 51 153

In the RGB field, the up and down arrow keys change the number under the cursor. Hold Shift to move it by 10.

The HEX and RGB fields also read code. Paste a CSS line, 0xFF663399, Color(0xFF663399), oklch() or a color name.

What these channels score for contrast

  • 2.50 to 1

    Black text on this color

    AA ✗AAA ✗AA large ✗

  • 8.41 to 1

    White text on this color

    AA ✓AAA ✓AA large ✓

White text is the stronger pairing on this color.

Type channels, copy code.

  • Tints from one color

    Slide Alpha to 40% and #663399 becomes #66339966, ready to copy as hex or rgb().

  • Convert once, not twice

    HSL rounds to whole numbers, so #2F80ED comes back as #3182ED. Always convert from the source.

  • One color, ten formats

    They sit under More, from Tailwind and OKLCH to SwiftUI, Flutter and Android XML.

Three channels, one string.

Each channel turns into two hex digits, and the pairs join up in order.

  1. A share of 255

    A channel runs from 0 to 255, so 102 fills 40% of its bar.

  2. Divide by 16

    102 is 6 sixteens with 6 left over, so it writes as 66.

  3. Always two digits

    A channel under 16 takes a leading zero, so 10, 20, 30 is #0A141E.

  4. Score the result

    White text scores 8.41 to 1 on #663399. Black reaches 2.50, so white is your pairing.

How to convert RGB to HEX.

  1. Enter three channels

    Type 102, 51, 153 with commas or spaces, or paste an rgb() line.

  2. Tune it live

    Drag the sliders, or use the arrow keys. Shift moves a number by 10.

  3. Copy the hex

    One click for hex, or open More for a CSS variable or app code.

The custom property trick.

Store the three numbers and one token gives you every opacity. The More row prints them as Channels only.

Store the numbers

--brand: 102 51 153;
background: rgb(var(--brand));
background: rgb(var(--brand) / 12%);

Not the function

--brand: rgb(102, 51, 153);
/* comes out transparent */
background: rgba(var(--brand), .12);

RGB to HEX questions.

All free tools
When do I need RGB instead of hex?

Whenever you compute with the color: canvas pixels, gradient stops, chart scales and contrast math all work on the numbers. For a hex string someone sent you, HEX to RGB is this same converter.

Should I write rgb() with commas or spaces?

Either: rgb(102, 51, 153) and rgb(102 51 153) are the same color in current browsers, and rgba() is now an alias. Alpha takes a slash in the modern form: rgb(102 51 153 / 40%).

What happens to a value over 255?

It is clamped: 300 becomes 255 and the status line says so, instead of rejecting the whole color. The fields also read percentages and values from 0 to 1.

Why does my gradient turn gray in the middle?

Because plain sRGB mixes channel by channel, and blue and yellow meet at flat gray. When the midpoint matters, mix in oklch: color-mix(in oklch, ...) or linear-gradient(in oklch, ...).

What contrast should the color reach?

4.5 to 1 for body text, 3 to 1 for large text (24px, or 18.66px bold) and 7 to 1 for AAA. The tool scores black and white, and the contrast checker takes any other pair.

Start with the design
you already have.

Install the Figma plugin, send a frame across, and finish it on the canvas.