Hex to RGB Converter
Paste a hex code, rgb(), hsl(), a decimal RGB triplet or a CSS colour name, or choose a colour with the picker. Convert its opaque sRGB channels to hex, RGB, HSL and normalized 0–1 RGB, with text contrast and lighter or darker shades.
Colour converterType a hex code, an rgb() value, an hsl() value or a colour name
- Colour
Common questions
- How does hex relate to RGB?
- They are the same three numbers written differently. #1A2B3C is three pairs of hexadecimal digits: 1A is 26, 2B is 43, 3C is 60, which is exactly rgb(26, 43, 60). Hex is compact and came from the web's early days; RGB is easier to adjust by hand. Neither is more precise than the other.
- When can a hex code be shortened to three digits?
- Only when each pair repeats: #AABBCC becomes #ABC, and #FFFFFF becomes #FFF. #1A2B3C cannot be shortened, because the shorthand expands by doubling each digit and would give a different colour. The tool tells you which case you are in rather than silently rounding.
- What is HSL useful for?
- Adjusting a colour rather than specifying one. Hue, saturation and lightness map onto how people actually think about colour. Making something "the same blue but lighter" is one number in HSL and guesswork in hex. The lighter and darker steps on this page are generated exactly that way, holding hue and saturation while varying lightness.
- What does the contrast ratio tell me?
- It compares black or white text with the converted opaque colour using the WCAG sRGB contrast formula. AA asks for at least 4.5:1 for normal text and 3:1 for large text. The tool chooses the better of black and white. This swatch check does not certify a whole page, or measure translucent text and backgrounds.
- Are CSS colour names exact?
- Yes. All 148 opaque CSS Color 4 named colours are supported, including rebeccapurple (#663399) and aliases such as gray/grey and aqua/cyan. Names map to fixed sRGB values. A CSS name is shown only when the output has an exact match; contextual keywords such as currentColor are not supported.
- What about alpha and transparency?
- Alpha in rgba(), hsla(), #RGBA and #RRGGBBAA is parsed and explicitly ignored. Transparent maps to black with an ignored zero-alpha note. All outputs, shades and contrast use full opacity; no background is composited. Alpha outside 0–1 or 0–100% is clamped as in CSS, then ignored. Invalid alpha is refused.
- How do I convert hex to RGB values from 0 to 1?
- Read the RGB 0–1 row. It divides each 8-bit channel by 255: #1A2B3C is 26, 43, 60 in decimal RGB, or 0.101961, 0.168627, 0.235294 with six decimals. These are normalized sRGB channels, not gamma-decoded linear-light values. Numeric RGB input still uses whole channels from 0 to 255; fractional input can use percentages.
- Which RGB and HSL inputs are supported?
- Use comma or space RGB functions, bare decimal triplets, RGB percentages, or HSL with saturation and lightness percentages. Optional alpha uses a fourth comma value or / with space notation. Hue accepts degrees, grad, rad and turn and wraps around the colour wheel. Saturation and lightness clamp to 0–100% with a visible note. Complete finite channels are required; trailing text and malformed functions are refused.
- Can I choose a colour without typing a code?
- Yes. Use Pick a colour to open your browser’s native colour picker. Selecting an opaque colour updates all conversion rows. A lighter or darker shade can also be loaded into the same converter.
- Can this convert RGB and hex to CMYK or Pantone?
- Use the related RGB to CMYK Converter for algebraic RGB, hex and CMYK channel arithmetic. It does not simulate an ICC printing profile. This page has no CMYK output, Pantone library or Pantone match; a spot-colour selection requires the relevant licensed reference and print conditions.
- How are HSL precision and saved colours handled?
- HSL output retains four decimal places where needed so the printed notation converts back to the same byte channels. Normalized RGB uses six decimals. Valid deliberate edits save in this browser; restoration is read-only and blank or invalid drafts preserve the previous saved colour. Forget saved colour removes storage while leaving the current result on screen. If copying is refused, select a notation or the complete summary and copy it manually.
Hex and integer RGB preserve the same 8-bit sRGB channels. HSL and percentage inputs round to those channels; displayed HSL and normalized RGB are rounded. Alpha is ignored explicitly, with no background compositing.