Colour on the web is defined numerically, but not every browser, tool, or designer works in the same format. Understanding each colour code format — and when to use it — makes you a faster, more confident designer and developer.
The Nine Most Common Colour Formats
- HEX: Six hexadecimal digits prefixed with #. Compact and widely used in HTML and CSS. Example:
#783F8E. - RGB: Red, Green, Blue — each from 0 to 255. Natural for additive colour work. Example:
rgb(120, 63, 142). - RGBA: RGB with an alpha channel from 0 to 1. Essential for transparency. Example:
rgba(120, 63, 142, 0.8). - HSL: Hue (0–360°), Saturation (%), Lightness (%). The most intuitive format for designers — mentally adjusting hue or lightness is easy. Example:
hsl(279, 38%, 40%). - HSV / HSB: Hue, Saturation, Value/Brightness. Used in many colour pickers and graphic design tools. Example:
hsv(279, 56%, 56%). - CMYK: Cyan, Magenta, Yellow, Key (black). The print standard. Every digital colour needs conversion before it goes to a printing press. Example:
cmyk(15%, 56%, 0%, 44%). - CSS: The ready-to-paste declaration for CSS files:
color: #783F8E; - Tailwind: Arbitrary value syntax for Tailwind CSS:
text-[#783F8E]. - Android XML: The 8-digit #AARRGGBB format used in Android layouts. Example:
#FF783F8E.
Colour Harmonies Explained
- Complementary: Two colours opposite each other on the colour wheel. High contrast, very punchy.
- Analogous: Three colours next to each other on the wheel. Calm, cohesive, great for backgrounds.
- Triadic: Three colours evenly spaced around the wheel. Vibrant and playful.
- Tetradic: Four colours forming a rectangle. Rich and complex — great for brand palettes.
- Split-complementary: A base colour plus the two colours adjacent to its complement. High contrast but easier on the eye than pure complementary.
- Monochromatic: A single hue with variations in saturation and lightness. Elegant and minimal.
Shades and Tints
A tint is a colour mixed with white — it becomes lighter. A shade is a colour mixed with black — it becomes darker. Together they create a range around your base colour that lets you build consistent UI, backgrounds, buttons, and hover states from a single hex. This tool generates 8 tints and 8 shades automatically.
Contrast and Accessibility
The WCAG (Web Content Accessibility Guidelines) set contrast ratios that text needs to be readable:
- 4.5:1 or higher: Required for normal body text (AA standard).
- 3:1 or higher: Required for large text (18pt+ or 14pt bold).
- 7:1 or higher: AAA standard — the highest accessibility tier.
This tool shows you both white-on-color and black-on-color contrast ratios so you can check legibility instantly.
Best Practices
- Pick a base and build from it: Use one primary colour, generate tints and shades, and design your whole UI from that single palette.
- Use HSL for design: Adjusting lightness is much easier than tweaking RGB values.
- Check contrast before shipping: Two colours can look great together on your monitor and still fail WCAG on a user's device.
- Keep your palette small: One primary, one accent, plus neutrals. Less is more.
- Test in dark mode: A colour that works on white can look muddy on dark.
- Use HEX for the web, CMYK for print: Never send a HEX code to a printer.
Privacy and Security
Most online colour tools upload your images to their servers. ToolBajar's Color Code Generator processes everything locally — your images are read by your browser and never sent anywhere. Your favourites and recent colours are stored in your browser's local storage, not on any server.