Hex to RGB Converter
Paste a colour in whatever notation you have, whether hex, rgb(), hsl(), a bare triplet or a CSS name, and get all the others, along with a contrast check and a set of lighter and darker steps built from the same hue.
Colour converterType a hex code, an rgb() value, an hsl() value or a colour name
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?
- Whether text will be readable on that colour. WCAG asks for at least 4.5:1 for normal body text and 3:1 for large text; the scale runs from 1:1 to 21:1. The tool picks whichever of black or white reads better and shows the ratio, so you can tell at a glance whether a background is usable.
- Are CSS colour names exact?
- Yes, each of the 140 named colours maps to one fixed hex value. teal is always #008080. They are convenient but limited, which is why this tool shows the name only when a colour happens to have one.
- What about alpha and transparency?
- An alpha value in rgba() or hsla() is accepted and ignored, since it describes how a colour composites rather than the colour itself. The converted values describe the colour at full opacity.
Exact. Colour space conversion is deterministic arithmetic, shown so you can check it.