RGB, HEX and HSL: One Colour, Three Notations
Screens create colour by mixing red, green and blue light. Every colour you see on a website or app can be described by how much of each it contains. Designers and developers write those amounts in different formats depending on the tool: CSS often uses HEX codes like #FCA311, image editors show RGB values like rgb(252, 163, 17), and HSL is handy for building colour palettes.
This converter lets you pick a colour with sliders and instantly gives you the matching HEX, RGB and HSL codes, ready to copy into your stylesheet or design file.
How to Use the RGB to HEX Converter
- Move the Red, Green and Blue sliders, or type values from 0 to 255.
- Watch the preview box update as you adjust.
- Click a Quick Preset to start from a common colour.
- Copy the HEX, RGB or HSL code with one click.
How RGB to HEX Conversion Works
HEX is simply the three RGB numbers written in base 16 (hexadecimal), where digits run 0–9 and then A–F. Each colour channel becomes two hex digits.
Example: RGB(252, 163, 17)
- 252 ÷ 16 = 15 remainder 12 → F, C →
FC - 163 ÷ 16 = 10 remainder 3 → A, 3 →
A3 - 17 ÷ 16 = 1 remainder 1 → 1, 1 →
11
Result: #FCA311 — the warm orange used as the accent colour on this website.
To go back from HEX to RGB, split the code into pairs and convert each from base 16: 14 = 20, 21 = 33, 3D = 61, so #14213D = rgb(20, 33, 61).
Common Colour Codes
| Colour | HEX | RGB |
|---|---|---|
| Black | #000000 | 0, 0, 0 |
| White | #FFFFFF | 255, 255, 255 |
| Red | #FF0000 | 255, 0, 0 |
| Green | #00FF00 | 0, 255, 0 |
| Blue | #0000FF | 0, 0, 255 |
| India saffron | #FF9933 | 255, 153, 51 |
| India green | #138808 | 19, 136, 8 |
| Navy blue | #000080 | 0, 0, 128 |
When to Use Each Format
- HEX — compact and universal in CSS, HTML, Figma and brand guidelines.
- RGB / RGBA — useful when you need transparency (
rgba(0, 0, 0, 0.5)) or when changing colours with JavaScript. - HSL — best for building palettes: keep the hue, then raise or lower the lightness to get tints and shades that clearly belong together.
Colour and Accessibility
Good-looking colours are not always readable. The Web Content Accessibility Guidelines (WCAG) recommend a contrast ratio of at least 4.5:1 between normal text and its background. Light grey text on white, or yellow on white, often fails this test. Dark navy on white or white on dark navy usually passes comfortably. Always check contrast for buttons and body text, especially for users with low vision or on bright mobile screens outdoors.
Related Tools
- CSS Formatter — tidy up stylesheets after adding colours.
- HTML Formatter — beautify your markup.
- Text to Binary — explore how numbers are stored in different bases.