Hex to RGB Converter
Paste #abc, #aabbccdd, rgb() or hsl() and get the same color in hex, RGB and HSL with alpha and a live swatch. Reads 3, 4, 6 and 8 digit hex codes.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Hex to RGB Converter?
Paste a color code in any common CSS form and read it back in all three: hex, rgb() and hsl(), each with its own copy button and a live swatch so you can see what you are working with. Shorthand #abc, full #aabbcc, eight-digit #aabbccdd with alpha, rgb(), rgba(), hsl() and hsla() are all accepted, with commas or spaces between the numbers.
This page is the fast lane for one job: a code arrives in a ticket, a design file or someone's message, and you need it in a different notation right now. When you want to choose a color visually, explore shades or compare formats side by side with HSV, the Color Picker and Converter is the better tool; this one starts from the code.
Alpha comes along for the ride. Paste #00000080 and the outputs read rgb(0 0 0 / 0.5) and hsl(0 0% 0% / 0.5), with the hex keeping its fourth pair. The conversion runs in the page and the share link reopens the converter with your color filled in.
- Accepts 3, 4, 6 and 8 digit hex plus rgb(), rgba(), hsl() and hsla()
- Hex, RGB and HSL output with a copy button on each
- Alpha preserved across all three notations
- Live swatch of the parsed color
- Converts in the page, with a shareable link to the exact color
Updated
How to use the Hex to RGB Converter
- Paste or type a color into the input: hex with or without alpha, rgb() or hsl(), commas or spaces.
- Check the swatch; if the input cannot be read, the page says so and shows examples of accepted forms.
- Read the hex, RGB and HSL lines, and copy whichever notation your code needs with its button.
- Try the preset chips to see how shorthand, rgb(), hsl() and an alpha hex each behave.
Worked examples
Hex to RGB and HSL
Input
#1e90ff
Output
rgb(30 144 255) and hsl(210 100% 56%)
1e is 30, 90 is 144 and ff is 255. Blue dominates, so the hue lands at 210 degrees on the blue side of cyan, fully saturated at 56% lightness.
Eight-digit hex with alpha
Input
#00000080
Output
rgb(0 0 0 / 0.5)
The first three pairs are black; the final 80 is 128 of 255, which rounds to 0.5 alpha. The HSL line carries the same / 0.5 suffix.
rgb() in, hex out
Input
rgb(34 197 94)
Output
#22c55e and hsl(142 71% 45%)
The conversion works from any accepted notation, not just from hex. 34 in base 16 is 22, 197 is c5, 94 is 5e.
Shorthand expansion
Input
#f80
Output
#ff8800, rgb(255 136 0), hsl(32 100% 50%)
Each shorthand digit is doubled, so f becomes ff and 8 becomes 88. The hex line shows the expanded six-digit form.
Background and insight
A hex code is three numbers in base 16 wearing a trench coat. Each pair of digits is one channel of light, red then green then blue, running from 00 (none) to ff (full), which is 0 to 255 in decimal. That range exists because each channel gets 8 bits, giving 256 levels and about 16.7 million combinations. A fourth pair, standardized in CSS Color Module Level 4, encodes alpha the same way, so 80 is 128 out of 255, almost exactly half opaque.
The three-digit shorthand works by doubling: #abc expands to #aabbcc, so every shorthand color is one whose channels repeat a digit. That is also why #f80 and #ff8800 are the same orange and why not every color has a short form.
HSL is the same sRGB color addressed differently, as a point in a cylinder rather than a cube. Hue is the angle around the wheel, with red at 0, green at 120 and blue at 240 degrees; saturation is the distance from the gray axis; lightness runs from black at the bottom to white at the top. Designers reach for it because "darker" or "less intense" is one number in HSL and three coupled numbers in RGB. The modern CSS syntax this tool emits separates values with spaces and puts alpha after a slash, a Color Level 4 change from the older comma form, and both remain valid in every current browser.
Common use cases
Design handoff to CSS
A mockup annotates #1e90ff but your stylesheet keeps colors as hsl() variables; paste once and copy the matching line.
Decoding alpha hex
Make sense of an eight-digit code from a theme file by seeing its opacity as a plain 0 to 1 number.
Normalizing a codebase
Translate stray rgb() and shorthand hex values into the one notation your lint rules expect.
Checking a color by eye
Paste a code from a bug report and confirm against the swatch that it really is the gray someone complained about.
Tips and limitations
- Named CSS colors such as rebeccapurple are not recognized here; paste the hex or rgb() value instead.
- Legacy comma syntax is fine on input: rgb(30, 144, 255) and rgba(0,0,0,.5) parse the same as the space-separated forms.
- Alpha can be given as a fraction or a percentage: rgb(0 0 0 / 50%) and / 0.5 mean the same thing.
- HSL values are shown as whole numbers, so converting a color to HSL and typing it back can land a channel one step away. Keep hex or RGB as the stored source of truth.
- hsl(0 0% 50%) and hsl(240 0% 50%) are the identical gray: at zero saturation the hue angle carries no information.
Sources and further reading
- CSS Color Module Level 4, W3C. Hex notation including 4 and 8 digits, and the space-separated rgb() and hsl() syntax
- <hex-color>, MDN Web Docs. How the 3, 4, 6 and 8 digit forms are read
- hsl() CSS function, MDN Web Docs
Frequently asked questions
How do I read a hex color code by hand?
Split it into pairs: red, green, blue. Each pair is a base-16 number from 00 to ff, meaning 0 to 255. The first digit counts sixteens and the second counts ones, so 90 is 9 times 16, which is 144, and ff is 255. A high first pair relative to the others means the color leans red, and so on.
What do the last two digits of an 8-digit hex code mean?
They are the alpha channel, opacity encoded the same way as the color channels. ff is fully opaque, 00 fully transparent, and 80 is 128 of 255, which this converter shows as / 0.5 in the rgb() and hsl() outputs.
Why does the rgb() output use spaces instead of commas?
CSS Color Module Level 4 introduced the space-separated form, rgb(30 144 255 / 0.5), and it is now the syntax most style guides prefer. The older comma form still works in every browser, and this page accepts either on input.
Can I paste rgb() or hsl() values instead of a hex code?
Yes. The input accepts rgb(), rgba(), hsl() and hsla(), with commas or spaces and with alpha as a fraction or percentage, and converts from there to the other notations. Hue may carry a deg suffix or not.
How is RGB turned into HSL?
The channels are scaled to 0 to 1, then lightness is the midpoint of the largest and smallest channel, saturation measures how far apart they are relative to the lightness, and hue comes from which channel leads and by how much, mapped onto a 360 degree wheel. The page rounds each result to a whole number for readable CSS.
Is #abc the same color as #aabbcc?
Yes, exactly. Shorthand hex doubles each digit, so a becomes aa and c becomes cc. The same rule gives four-digit shorthand with alpha: #abcd expands to #aabbccdd.
Is there an in-depth guide to the Hex to RGB Converter?
Yes. “Unit Conversion Factors: Exact Definitions, Gallons and Temperature Offsets” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.