How a hex code is put together
A hex colour is three bytes written in base 16 after a # sign: two digits for red, two for green, two for blue. Base 16 uses the digits 0 to 9 and then A to F for the values 10 to 15, so a pair runs from 00 to FF, the same range as 0 to 255 in decimal.
To read a pair, multiply the first digit by 16 and add the second. In #1E6FD9 the red pair 1E is 16 plus 14, or 30; the green pair 6F is 96 plus 15, or 111; the blue pair D9 is 208 plus 9, or 217. The code is therefore identical to rgb(30, 111, 217), and browsers treat both as the same sRGB colour.
With practice you can judge a code at a glance. Three equal pairs, as in #808080, mean a neutral grey. A large first pair followed by two small ones is a red, and high values in all three pairs mean a pale colour close to white.
Three-digit shorthand
CSS allows a three-digit form in which each digit is doubled: #16f is #1166ff, #fff is white and #000 is black. A common misreading pads with zeros instead and takes #16f for #10600f, which is a dark green and nowhere near the bright blue the shorthand means.
Only colours whose pairs are all doubled digits can be shortened, which leaves 4,096 of the 16.7 million. The converter expands shorthand on input and always prints six uppercase digits in the HEX row, so you can paste #16f and copy #1166FF for a tool that rejects the short form.
Alpha in four and eight digits
Current CSS adds an optional alpha value to the notation: #RRGGBBAA, with #RGBA as its shorthand. The extra pair sets opacity on the same 00 to FF scale, so FF is opaque, 00 is invisible and 80 is close to half. Percentages do not map onto it directly, which is why 50 percent opacity is written 80 and not 50.
Order is a trap when codes move between platforms. CSS puts alpha last, while Android colour resources put it first as #AARRGGBB. This converter accepts neither: any four- or eight-digit code is refused with the message Couldn't read that colour. Strip the alpha digits and convert the opaque colour underneath.
What the field accepts and what comes back
Type or paste six or three hex digits, in either case, with or without the #. The preview block shows the colour with its code printed on it, and All formats lists HEX first, then RGB, HSL, HSV / HSB and CMYK. A half-typed code shows a red outline while the panels hold the last valid colour, except at exactly three digits, which is valid shorthand.
The same field reads other notations if you paste them: three comma-separated numbers are taken as RGB, and rgb(), hsl(), hsv() and cmyk() values are converted too. One catch on this page is that three bare digits such as 123 are read as the shorthand #112233, not as numbers.
Checking a hex colour for readable text
The Contrast card puts your colour on white and on black and reports each ratio to two decimals with a grade. WCAG AA needs 4.5:1 for normal text and 3:1 for large text. AAA needs 7:1. A link blue such as #0066CC scores 5.57:1 on white and passes AA, but only 3.77:1 on black, where it is fit for large text alone.
When a brand colour misses the mark, the Shades strip offers five darker versions mixed towards black and the Tints strip five lighter ones mixed towards white. The card tests white and black backgrounds only. For print values see the CMYK Color Converter, and for adjusting hue or saturation the HSV Color Converter.