Skip to content

RGB to HEX converter

Type rgb(46, 139, 87), get #2e8b57 — and HSL and OKLCH too.

Runs in your browser — files never leave your device
HEX#2e8b57
RGBrgb(46, 139, 87)
HSLhsl(146, 50%, 36%)
OKLCHoklch(56.9% 0.119 154.9)

Convert RGB colors to HEX codes

Type an rgb() value — comma- or space-separated — or use the colour picker, and get the six-digit hex code to paste into CSS, a design tool or a brand guide. HSL and OKLCH are shown too, with a live swatch.

How RGB becomes a hex code

Each channel runs from 0 to 255, which fits in exactly two hexadecimal digits. Convert each one and write them side by side, red first:

rgb(255, 165, 0) → ff, a5, 00 → #ffa500 (orange).

Single-digit results get a leading zero — 0 becomes 00, 9 becomes 09 — otherwise the channels shift and you get a different colour. Opacity has no place in a six-digit code; keep it in rgb() or CSS opacity.

Other conversions with this tool

How to convert RGB to HEX

  1. 1

    Type an rgb() value or pick a colour.

  2. 2

    Read the HEX code next to the swatch.

  3. 3

    Copy it straight into your CSS.

RGB to HEX — frequently asked questions

How do you convert RGB to HEX by hand?

Write each channel (0–255) as two hex digits and join them. rgb(46, 139, 87) → 2E, 8B, 57 → #2E8B57.

Does it accept the modern rgb(46 139 87) syntax?

Yes — both comma- and space-separated CSS syntax. An alpha value is ignored, because a six-digit hex code has no opacity.

Is #2E8B57 the same as #2e8b57?

Yes. Hex colours are case-insensitive.