Color Converter
Convert colours between HEX, RGB, HSL, HSV, CMYK and decimal, with a live swatch, WCAG contrast ratios against white and black, and the complementary colour.
Swatch with the more readable text colour, and the complementary colour.
HEX
#2563EB
RGB
rgb(37, 99, 235)
HSL
hsl(221, 83%, 53%)
HSV / HSB
hsv(221, 84%, 92%)
CMYK
cmyk(84%, 58%, 0%, 8%)
Decimal
24,50,411
Contrast on White
5.17:1 (AA pass)
Contrast on Black
4.06:1 (AA large only)
Complementary
#DA9C14
Colour Code Converter
Enter a HEX code or set the red, green and blue values. The calculator shows the colour in every common format and checks how readable text would be on it.
Formulas
- HEX: each channel 0 to 255 as two hex digits
- HSL: L = (max + min)/2; S = (max − min)/(1 − |2L − 1|); H from which channel is largest
- CMYK: K = 1 − max; C = (1 − R − K)/(1 − K)
- Luminance L = 0.2126 R + 0.7152 G + 0.0722 B (linearised); contrast = (L1 + 0.05)/(L2 + 0.05)
Common colours
| Colour | HEX | RGB | HSL |
|---|---|---|---|
| Red | #FF0000 | 255, 0, 0 | 0°, 100%, 50% |
| Saffron | #FF9933 | 255, 153, 51 | 30°, 100%, 60% |
| India green | #138808 | 19, 136, 8 | 115°, 89%, 28% |
| Navy | #000080 | 0, 0, 128 | 240°, 100%, 25% |
| Mid grey | #808080 | 128, 128, 128 | 0°, 0%, 50% |
Worked examples
1. #2563EB (the default blue). rgb(37, 99, 235); hsl(221, 83%, 53%); contrast 5.17:1 on white, so white text passes AA.
2. Saffron #FF9933. rgb(255, 153, 51); white text only 2.13:1, black text 9.86:1.
Screen colours are sRGB; print (CMYK) results vary with paper and printer profiles.
Related tools
- Hex numbers: Binary Calculator. Text bytes: Encoding Calculator.
Frequently Asked Questions
How do I convert HEX to RGB?
Split the six digits into pairs and convert each from hexadecimal: #2563EB → 25 = 37, 63 = 99, EB = 235, so rgb(37, 99, 235).
How do I convert RGB to HEX?
Write each value 0 to 255 as two hex digits and join them: rgb(255, 153, 51) → FF 99 33 → #FF9933.
What is a 3-digit hex code?
Shorthand where each digit is doubled: #F93 = #FF9933.
What is HSL?
Hue (0 to 360° around the colour wheel), saturation and lightness (percent). It is easier to adjust by hand than RGB: change lightness to make tints and shades.
How is RGB converted to CMYK?
K = 1 − max(R, G, B)/255; C = (1 − R/255 − K)/(1 − K), and similarly for M and Y. Printed colours also depend on the printer's colour profile, so treat this as a starting point.
What is a contrast ratio?
(L1 + 0.05) ÷ (L2 + 0.05), where L is relative luminance. It ranges from 1:1 to 21:1 (black on white).
What contrast do I need for accessibility?
WCAG 2 level AA needs 4.5:1 for normal text and 3:1 for large text (18 pt, or 14 pt bold); AAA needs 7:1 and 4.5:1.
What is the decimal colour value?
The 24-bit number R × 65,536 + G × 256 + B, used in some programs and APIs.
What is the complementary colour?
The colour opposite on the RGB wheel, found here by subtracting each channel from 255.
What are the Indian flag colours?
Commonly used digital values are saffron #FF9933, white #FFFFFF, green #138808 and navy blue #000080 for the chakra.
Related Calculators
Binary Calculator
Convert between decimal, binary, octal, and hexadecimal number systems. Perform bitwise AND, OR, XOR, NOT, and shift operations.
Encoding Calculator
Calculate string encoding sizes, byte representations, and storage requirements for different character encodings.
Floating Point Calculator
Convert a decimal number to its IEEE 754 floating point representation. View sign, exponent, and mantissa bits for single and double precision.
CRC Calculator
Calculate Cyclic Redundancy Check (CRC) values using polynomial division. Enter data and generator polynomial to compute CRC checksum.
Hamming Distance Calculator
Calculate the Hamming distance between two binary values. Determine the number of differing bit positions and error detection capability.
Boolean Algebra Calculator
Evaluate Boolean logic gates (AND, OR, XOR, NAND, NOR) for up to 3 inputs. View truth table outputs and minterm expressions.
More in Computer Science · Engineering calculators · All calculators A–Z