Color Converter
Convert between HEX, RGB, and HSL with a live picker.
Convert RGB color values to a HEX code instantly. Enter red, green, and blue channels and copy the compact hex code, ready for CSS and design handoff. Everything runs 100% client-side in your browser, so your data never leaves your device.
RGB channels
HSL channels
Going from RGB to HEX is the reverse trip: you take three decimal channel values, each between 0 and 255, and rewrite each one as a two digit base 16 number. Stick the three results together, add a hash in front, and you have a HEX code.
The steps:
The one thing people get wrong is dropping a leading zero. Every channel must become exactly two hex characters. A red value of 5 converts to 05, not 5, because a HEX code is read in fixed pairs. If you wrote #553 instead of #050503 the browser would read it as a completely different color, or as an invalid shorthand. When a channel converts to a single digit, pad it with a leading zero before joining the pairs.
If RGB gives you the raw numbers, why convert back to HEX at all? Convenience. A HEX code is a single compact token, seven characters including the hash, that you can copy, paste, and share without commas, spaces, or a function wrapper. Design tools, style guides, and CSS variables almost all default to HEX because one string is easier to pass around than three separate numbers. It also reads cleanly in a diff and slots straight into a color swatch. RGB earns its keep when you are doing math on the channels, but for storing and communicating a fixed color, HEX is the tidier choice, which is why it remains the lingua franca of web color.
CSS ships with a set of keyword colors you can write by name instead of a code. They map to exact HEX and RGB values, so the table below is handy when you want to sanity check a conversion or reach for a familiar color without opening a picker.
| Name | HEX | RGB |
|---|---|---|
| black | #000000 | rgb(0, 0, 0) |
| white | #FFFFFF | rgb(255, 255, 255) |
| red | #FF0000 | rgb(255, 0, 0) |
| green | #008000 | rgb(0, 128, 0) |
| blue | #0000FF | rgb(0, 0, 255) |
| yellow | #FFFF00 | rgb(255, 255, 0) |
| cyan | #00FFFF | rgb(0, 255, 255) |
| magenta | #FF00FF | rgb(255, 0, 255) |
| silver | #C0C0C0 | rgb(192, 192, 192) |
| gray | #808080 | rgb(128, 128, 128) |
| orange | #FFA500 | rgb(255, 165, 0) |
| purple | #800080 | rgb(128, 0, 128) |
| teal | #008080 | rgb(0, 128, 128) |
| navy | #000080 | rgb(0, 0, 128) |
Need a different color task? Browse every free developer tool including color converters, encoders, and hashing utilities.