HEX to RGB converter
Paste a hex value and read it back as RGB, HSL and CSS, with the contrast against black and white. It runs in this tab, so nothing is uploaded.
These are the values for the last color that parsed. The message above says what is wrong with the one in the field.
#2F80ED
- RGB rgb(47, 128, 237)
- HEX #2F80ED
- HSL hsl(214, 84%, 56%)
- CSS #2F80ED
- 47 128 237
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, 0xFF2F80ED, Color(0xFF2F80ED), oklch() or a color name.
Contrast against black and white
-
5.43 to 1
Black text on this color
AA ✓AAA ✗AA large ✓
-
3.87 to 1
White text on this color
AA ✗AAA ✗AA large ✓
Black text is the stronger pairing on this color.
Any hex, read right.
-
Shorthand, spelled out
#ABC is #AABBCC with every digit doubled, so only repeating pairs have a short form. A fourth digit is alpha.
-
The Android alpha trap
Android writes alpha first. Switch on Alpha first and purple #802F80ED becomes #2F80ED at half strength.
-
Paste the whole line
The fields read a CSS line, 0x values, Flutter code, oklch() and color names, so skip the cleanup.
What a hex color actually is.
Six digits, three channels. Each pair is one number from 0 to 255, written in base 16.
One pair, one channel
Hex is RGB written in base 16. 2F is red, 80 is green, ED is blue.
Sixteens plus the rest
The first digit counts sixteens and the second adds ones. 2F is 2 × 16 + 15, which is 47.
FF is the ceiling
Two hex digits top out at FF, which is 255, a full bar.
Channels add up
Light all three and you get #2F80ED, where black text scores 5.43 to 1.
How to convert HEX to RGB.
-
Paste your hex
A bare value or a whole CSS line, upper or lower case. Every field updates as you type.
-
Nudge it
Drag a channel slider, or press the arrow keys in the RGB field.
-
Copy what you need
RGB, HSL or CSS in one click, or open More for Tailwind, SwiftUI and Flutter.
Every length the field reads.
| Length | Try it | Reads as | Alpha |
|---|---|---|---|
| 3 digits | #ABC | #AABBCC, every digit doubled | Stays as set |
| 4 digits | #ABCD | #AABBCC | 86.7%, from D doubled |
| 6 digits | #2F80ED | 47, 128, 237 | Stays as set |
| 8 digits | #2F80ED80 | 47, 128, 237 | 50.2%, from the last pair |
| 0x and 8 digits | 0xFF2F80ED | 47, 128, 237 | 100%, from the first pair |
| Any other length | #2F80E | Refused, with the reason. The last good color stays | No change |
HEX to RGB questions.
Is hex a different color space from RGB?
No, hex is the same three sRGB channels written in base 16, so nothing is lost either way. For the other direction, RGB to HEX is this same converter.
Why is my eight-digit hex the wrong color?
Its alpha is probably at the front, since CSS reads #RRGGBBAA and Android writes #AARRGGBB. Switch on Alpha first, which appears for eight digits, and 0xFF2F80ED turns it on by itself.
Why do designers hand over hex?
Because it is one token with no spaces, commas or brackets. It survives a Slack message, a JSON theme and a spreadsheet cell intact, even when the code that uses it wants numbers.
When do I need the channels back?
When you do something to a color rather than name it. A hover state, a tint, a gradient stop and a canvas fill are all arithmetic on three numbers.
Can hex describe every color?
No, only sRGB, so a Display P3 red or a vivid oklch() falls outside it. Paste one here and the tool clips the channels to fit, and tells you it did.
What does the contrast score mean?
It is the WCAG ratio against black and white, with alpha left out: body text needs 4.5 to 1, large text 3 to 1 and AAA 7 to 1. For any other pair, use the contrast checker.
More free tools
- RGB to HEX The other direction, with the same converter underneath.
- Mesh gradient generator Layered radial gradients, as CSS or as an image file.
- Gradient maker Linear and radial gradients. Take it as a PNG, as hex colors, or as CSS.
- Color contrast checker WCAG ratios for any pair, and the nearest color that passes when it fails.
- Palette from an image Pull the dominant colors out of a photo or a screenshot, in the browser.
- Random color One color or a whole palette, with the ones you like locked.
Start with the design
you already have.
Install the Figma plugin, send a frame across, and finish it on the canvas.