01What is Hex to RGB?
A design file hands you #3b82f6, but the code you are writing wants three numbers, or an hsl() value for a theme variable. This page does that translation in both directions, so you can also start from R, G and B and get the hex back. The hex side follows the CSS Color Module rules for hex notation. A six-digit code is read as three pairs, one byte per channel, so 3b becomes 59, 82 becomes 130 and f6 becomes 246. A three-digit code is shorthand, and each digit is doubled before parsing. That is why #38f turns into #3388ff and then rgb(51, 136, 255). The leading # is optional and letter case does not matter. Anything that is not exactly 3 or 6 hex digits gets a red message instead of a guess. Type #12345 and the tool tells you what it expects, while the swatch and the outputs keep showing the last valid color. Spaces count as invalid characters here, so trim a pasted value if it came with padding. Going the other way, the three number boxes accept any value, but the tool rounds it to a whole number and clamps it to the 0 to 255 range before building the hex. Type 300, 12.5 and -4 and you get #ff0d00, not a broken string. The native color picker next to the swatch feeds the same path. The All Formats panel shows four strings, each with its own copy button. You get the normalized lowercase six-digit hex, the classic comma form rgb(59, 130, 246), an HSL value, and the space-separated form rgb(59 130 246) from CSS Color Level 4. The HSL numbers come from the standard RGB to HSL formula, rounded to whole degrees and whole percentages. For #3b82f6 that gives hsl(217, 91%, 60%). Rounding is the main limit to keep in mind. Because HSL is rounded, converting the HSL string back can land one step away from the original hex. Grays are a special case too. Any color where R, G and B are equal has no hue, so the tool reports hue 0 and saturation 0. There is no alpha support on this page. Four- and eight-digit hex codes are rejected rather than having their alpha silently dropped, so use Hex to RGBA for those. All of the math runs in the page script. The colors you type are not uploaded or stored.
Frontend developers who copy colors out of a design file and need them as rgb() or hsl() strings, or as raw channel numbers for canvas and shader code. The tool runs entirely in your browser, so your data never leaves your device.
02How to use Hex to RGB
- Type or paste a hex code into the HEX box, with or without the #
- Or set the three RGB number boxes, or pick a color with the native color picker next to the swatch
- Check the swatch and the red hint, which appears if the hex is not 3 or 6 digits
- Read the hex, rgb(), hsl() and CSS Color 4 strings in the All Formats panel
- Click the copy icon beside the format you need, or use reset to go back to #3b82f6
03Worked examples
- Input:
#3b82f6 - Result:
#3b82f6 · rgb(59, 130, 246) · hsl(217, 91%, 60%) · rgb(59 130 246) - The four strings shown in the All Formats panel.
- Input:
#38f - Result:
#3388ff · rgb(51, 136, 255) · hsl(215, 100%, 60%) - Shorthand is expanded by doubling each digit before parsing.
- Input:
FF6B35 - Result:
#ff6b35 · rgb(255, 107, 53) · hsl(16, 100%, 60%) - No # and uppercase both work. The output hex is lowercased.
- Input:
#808080 - Result:
rgb(128, 128, 128) · hsl(0, 0%, 50%) - Equal channels mean a gray, so hue and saturation are 0.
- Input:
R 300, G 12.5, B -4 - Result:
#ff0d00 · rgb(255, 13, 0) · hsl(3, 100%, 50%) - RGB boxes round to whole numbers and clamp to 0 to 255.
- Input:
#12345 - Result:
Enter 3 or 6 hex digits, e.g. #3b82f6 or #38f. Showing the last valid color. - Five digits is rejected. Outputs keep the previous valid color.
04Common use cases
- Turning a hex value from a Figma inspect panel into rgb(59, 130, 246) for a CSS custom property
- Getting separate R, G and B integers to pass into a canvas fillStyle or a shader uniform
- Expanding a 3-digit shorthand like #38f to the full six digits a config file or linter requires
- Writing an hsl() starting point for a theme so you can tweak lightness for hover and active states
- Checking what hex a set of RGB values from a screenshot color picker maps to
- Converting legacy comma rgb() values to the space-separated CSS Color 4 syntax during a stylesheet cleanup
05Tips
- The copied HEX is always the normalized six-digit lowercase form, even if you typed #38F, so it is safe to paste into configs that reject shorthand.
- Out-of-range RGB values are clamped, not rejected, so typing 999 quietly gives you 255. Double-check pasted numbers that look too high.
- HSL here is rounded to whole numbers, so a round trip through hsl() can shift a channel by one. Keep the hex as your source of truth.
- If your value has transparency (#RRGGBBAA), this page will flag it as invalid. Switch to Hex to RGBA rather than chopping off the last two digits by hand.
06Related concepts
CSS colors, sRGB color space, Color notation, HSL conversion.
Frequently Asked Questions
What is Hex to RGB?
Hex to RGB is a free, browser-based developer tool on AIDToolStack. Convert hex colors to RGB, HSL and other color formats. It requires no installation or sign-up and works entirely in your browser.
Is Hex to RGB free to use?
Yes. No sign-up, no fees and no usage cap.
Does Hex to RGB store my data?
No. It runs in your browser; nothing is uploaded.