RGB to Hex
Convert RGB to a hex color code and back: rgb(255, 136, 0) is #FF8800. Paste #abc, ff8800 or 255,136,0; each channel is a whole number 0 to 255. How it works
Use the RGB to Hex
About the RGB to Hex
rgb(255, 136, 0) is #FF8800 in hex: each channel from 0 to 255 becomes two hex digits, red first, so 255 is FF, 136 is 88 and 0 is 00. To convert RGB to hex by hand, divide a channel by 16 and write the quotient and the remainder as hex digits.
CSS named colors in RGB and hex
| Color name | RGB | Hex |
|---|---|---|
| black | rgb(0, 0, 0) | #000000 |
| white | rgb(255, 255, 255) | #FFFFFF |
| red | rgb(255, 0, 0) | #FF0000 |
| lime | rgb(0, 255, 0) | #00FF00 |
| blue | rgb(0, 0, 255) | #0000FF |
| yellow | rgb(255, 255, 0) | #FFFF00 |
| cyan | rgb(0, 255, 255) | #00FFFF |
| magenta | rgb(255, 0, 255) | #FF00FF |
| gray | rgb(128, 128, 128) | #808080 |
| silver | rgb(192, 192, 192) | #C0C0C0 |
| maroon | rgb(128, 0, 0) | #800000 |
| green | rgb(0, 128, 0) | #008000 |
| navy | rgb(0, 0, 128) | #000080 |
| purple | rgb(128, 0, 128) | #800080 |
| teal | rgb(0, 128, 128) | #008080 |
| olive | rgb(128, 128, 0) | #808000 |
| orange | rgb(255, 165, 0) | #FFA500 |
| rebeccapurple | rgb(102, 51, 153) | #663399 |
RGB values from the CSS Color Module Level 4 list of named colors; each hex code is the converter’s output for that RGB. CSS green is #008000; full-intensity green is lime.
What the hex field accepts
| You type or paste | Result |
|---|---|
| #abc | #AABBCC, rgb(170, 187, 204) |
| ff8800 | #FF8800, rgb(255, 136, 0) |
| rgb(255, 136, 0) | #FF8800, rgb(255, 136, 0) |
| 255,136,0 | #FF8800, rgb(255, 136, 0) |
| #12 | A hex code has 3 or 6 digits; this has 2. |
| #ff8800cc | Alpha (#RRGGBBAA) is not supported: enter 3 or 6 hex digits. |
| rgb(256,0,0) | Red is above 255: use a whole number from 0 to 255. |
Frequently asked questions
- How do I convert RGB to hex?
- Write each channel as two hex digits: divide by 16, and the quotient is the first digit and the remainder the second, with 10 to 15 written A to F. rgb(102, 51, 153) gives 66, 33 and 99: #663399.
- How do I convert hex to RGB?
- Split the code into three pairs and turn each pair into decimal: in #808080 each pair is 8 × 16 + 0 = 128, so rgb(128, 128, 128). Paste the code into the hex field and the three channels fill in.
- What is a 3-digit hex color?
- A short form in which each digit is doubled: #abc means #AABBCC, rgb(170, 187, 204). The converter accepts it with or without the #.
- Does the converter handle transparency (alpha)?
- No. 8-digit codes such as #ff8800cc and rgba() values get a message; enter 6 digits or rgb() with three channels.
- Why is my channel value rejected?
- Each channel must be a whole number from 0 to 255. 256, -1 or 12.5 get a message rather than being clamped, so the hex code always matches what you typed.
- Are hex color codes case sensitive?
- No. CSS treats #ff8800 and #FF8800 as the same color. The converter prints capitals and accepts either case as input; if your style guide wants lowercase, lowercase the copied code.
Related Tools
View all toolsColor Picker
Pick a color or type a HEX, RGB or HSL value to get the other two, the CSS and CMYK forms, and its WCAG contrast ratio on white, black or a second color.
Hex to RGBA Converter
Convert hex to rgba(): #007BFF is rgba(0, 123, 255, 1). Reads 3, 4, 6 and 8-digit hex or rgb()/rgba(), sets the opacity, and gives hsla() and 8-digit hex.
Color Contrast Checker
Enter a text and a background color, with opacity, to get the WCAG contrast ratio and AA and AAA pass or fail for normal and large text.
Color Palette Generator
Make a 5-color palette from one hex color: monochromatic, complementary, analogous, triadic or split-complementary, with WCAG contrast for each swatch.
Color Mixer
Mix two to four hex colors by weight in OKLab, sRGB or linear light: red and blue at 50% give #8c53a2 in OKLab. Copy HEX, RGB, HSL, OKLCH or CSS color-mix().
CSS Gradient Generator
Build linear, radial and conic gradients from color stops, ten presets or the colors of an image you upload, then copy CSS, Tailwind, React or SCSS code.