Tool

RGB to Hex Converter

Enter a red, green and blue value (0–255) to get the hex color code — plus HSL, HSV, CMYK, OKLCH and the closest named color.

The RGB field is focused below. Type 255, 90, 54 or paste rgb(255 90 54); every other format updates instantly.

Also accepts HSB — same values.
Approximate — calculated from RGB, for screen preview only.
Hex
RGB
RGB %
HSL
HSV / HSB
CMYK
OKLCH
Closest web-safe
Closest name

Want harmonies and shades too? Open this color in the full Color Picker.

How to convert RGB to hex

Type your three RGB values — red, green and blue, each from 0 to 255 — into the RGB field (it's focused for you), separated by commas or spaces. As you type, the hex color code appears in the results table on the right, along with RGB percentages, HSL, HSV, CMYK and OKLCH. Every output has a copy button, so grabbing #FF5A36 for a stylesheet is a single click. The tool also shows the closest web-safe color and the closest standard color name for the value you entered.

The RGB to hex formula

A hex color code is just the three RGB channels written in base 16 (hexadecimal) instead of base 10. Each channel becomes a two-digit hex number from 00 (0) to FF (255), and the three are concatenated behind a #. So rgb(255, 90, 54) converts channel by channel: 255 → FF, 90 → 5A, 54 → 36, giving #FF5A36. In code the one-liner is '#' + [r, g, b].map(v => v.toString(16).padStart(2, '0')).join(''). This tool does exactly that math, plus every other format, instantly and offline.

RGB to hex use cases

Going the other direction? Use the hex to RGB converter. Need HSL, CMYK or OKLCH from an RGB value at the same time? The full color converter shows all of them. And to explore shades and harmonies for the color, open it in the color picker or build a full scheme in the palette generator.

Why designers still convert RGB to a hex code

RGB and hex describe the same sRGB color — the conversion is exact and loses nothing — but hex has become the shared currency of web design. It is shorter, it copies as a single token with no punctuation to mangle, and it is the format that design tools, style guides, component libraries and CSS variables all default to. When a developer pastes --brand: #FF5A36 into a stylesheet, that one string is unambiguous; the equivalent rgb(255, 90, 54) is three values that a linter or a teammate might reformat. Converting your RGB value to hex once, at the point of handoff, keeps the rest of the pipeline clean. If your color needs an alpha channel, note that modern CSS also accepts 8-digit hex (#RRGGBBAA) — though rgba() or the newer rgb(r g b / a) syntax stays more readable for transparency.

RGB to hex values worth knowing

A handful of conversions come up so often they are worth committing to memory. rgb(0, 0, 0) is #000000 (black) and rgb(255, 255, 255) is #FFFFFF (white). Any color where all three channels are equal is a shade of gray — rgb(128, 128, 128) is #808080. The three primaries are #FF0000, #00FF00 and #0000FF; the secondaries are #FFFF00 (yellow), #00FFFF (cyan) and #FF00FF (magenta). Once you can see that FF means 255 and 00 means 0, most bright colors read at a glance. For everything in between, this converter does the base-16 math for you and shows the matching color name — or browse the 140 CSS color names and the full color library to find a name for the value you have.

RGB to hex FAQ

How do you convert RGB to hex by hand?

Convert each of the red, green and blue numbers (0–255) to a two-digit hexadecimal value, then join them behind a #. For example 255 is FF, 128 is 80, and 0 is 00, so rgb(255, 128, 0) becomes #FF8000.

What is rgb(255, 0, 0) in hex?

#FF0000 — pure red. Each channel converts on its own: 255 → FF, 0 → 00, 0 → 00.

How do I change an RGB value to hex in CSS?

You do not have to — CSS accepts rgb(255, 90, 54) and #FF5A36 interchangeably. Most teams still convert to hex for brand tokens and design-system variables because it is shorter and matches design-tool output. Paste your RGB value above and copy the hex result.

Can I convert an RGBA value with transparency?

The alpha channel becomes a fourth pair of hex digits (an 8-digit hex code), but this tool focuses on the opaque RGB portion. Enter just the R, G and B values to get the standard 6-digit hex code.

Is this RGB to hex converter free and private?

Yes — it's free with no sign-up, and the conversion runs entirely in your browser, so nothing you enter is uploaded.