About the RGB to HEX Converter
Color values from design apps, photo editors and code are often given as three numbers from 0 to 255, while stylesheets and brand guides use six-digit HEX codes. This RGB to hex converter writes each channel as two hexadecimal digits and joins them, so red 255, green 153 and blue 0 becomes #FF9900, and it shows the matching HSL value with a live swatch and CSS ready to copy. Sliders and number inputs make it easy to fine-tune each channel while watching the swatch, and an eight-digit HEX with transparency is available too. Matching colors exactly across a website, presentation and printed materials keeps a brand looking consistent. For the reverse conversion, use HEX to RGB, and to build matching colors, the Color Palette Generator.
Values can be typed in or set with the sliders, whichever suits you. Dragging is often the quicker way to reach a colour you cannot describe in numbers, such as the exact warmth of a sunset orange, because the swatch updates continuously and you judge the result at a useful size instead of guessing from figures.
An optional alpha setting adds transparency, giving you a HEX code with two extra characters as well as an rgba() value. If you type a number outside the allowed range, it is clamped to the nearest valid value and a short note tells you, so whatever you copy is always a colour that can genuinely be displayed, and a typing slip cannot slip into your stylesheet unnoticed.
How to use the RGB to HEX Converter
- Set red, green and blueType a number from 0 to 255 for each channel or drag its slider.
- Add transparency if neededMove the alpha slider anywhere between fully clear and fully solid.
- Read the resultsThe HEX and HSL values update live next to a swatch of the colour.
- Copy the codeEvery format has its own copy button.
RGB to HEX Converter features
- Number boxes and sliders for each channel
- A swatch that changes while you drag
- Results in five forms: plain HEX, HEX with transparency, rgb(), rgba() and hsl()
- Out-of-range numbers pulled back into range, with a note explaining why
- A surprise-me button that rolls new channel values
- One-click copy for every format
Common uses
- Turning RGB values from a design app into CSS
- Producing the six-character code for a shade picked out of a photo
- Converting a brand colour that was supplied as RGB
- Finding a colour by eye using the sliders
- Creating a translucent overlay colour for a photo caption
RGB to HEX in practice: matching a logo colour, sampling from the right source, decimal colour values, colour profiles and building a palette file
Designers, apps and devices often hand you colours as red, green and blue numbers, while websites and design platforms want HEX codes. This guide converts a sampled logo colour, explains why sampling from screenshots gives slightly wrong colours, converts decimal colour values from design tools, touches on colour profiles and shows how to keep converted colours organised.
A worked example: matching a logo colour
A shop owner samples the red from their logo with a phone app and gets 230, 57 and 70. Converted, that is #E63946, ready for the website's stylesheet and for design apps such as Canva, which accept HEX codes. Recording the code once, and reusing it everywhere, prevents slightly different reds creeping into posts, flyers and the website.
Sample from the original artwork
Colours sampled from screenshots, compressed images or photos of printed material drift from the true colour, because compression and lighting change the pixels. Sampling the same logo from a JPEG screenshot might give a value a few points away in each channel. Whenever possible, take colours from the original vector logo, the design file or the brand guide.
Decimal colour values
Some design and game tools express colours as decimals from 0 to 1 instead of 0 to 255. Multiply each value by 255 and round: 0.9, 0.22 and 0.27 become 230, 56 and 69, which is #E63845. Rounding differences of one point are invisible but matter if you need to match a code exactly, so convert once and reuse the HEX value.
Colour profiles
Web colours are defined in the sRGB colour space. Photos from recent phones may use a wider space, such as Display P3, and colours sampled from them can be outside what sRGB shows. Browsers convert between spaces automatically, but a colour sampled from a wide-gamut photo may look duller once used as a flat sRGB colour on a website.
Short codes
When each pair of digits in a HEX code is a repeated digit, such as #33AAFF, it can be shortened to #3AF. Shortening saves a few characters in stylesheets, but many teams prefer full six-digit codes for consistency and searchability, so that the same colour always appears in the same form.
Building a palette file
Collect converted colours in one place: CSS custom properties for the website, such as --brand-red: #E63946;, and a simple document listing each colour's name, HEX and RGB values for designers and printers. Future changes then mean editing one file rather than hunting through dozens of stylesheets and designs.
Transparency
Adding an alpha value produces an eight-digit code, with the last two digits setting opacity: 80 means about 50 percent and CC about 80 percent. Modern browsers support eight-digit codes, but some older tools and email clients do not, so use rgba values where compatibility matters.
Checking the result
After converting, paste the HEX code into a colour picker or preview and compare it with the original side by side. A swapped channel, such as green and blue reversed, produces a clearly different colour and is easy to spot at this stage.
Common mistakes
- Sampling brand colours from compressed screenshots.
- Rounding decimal colour values inconsistently.
- Using eight-digit codes where older software cannot read them.
- Storing the same colour in several slightly different forms.
Related tools
To convert back to RGB, use HEX to RGB Converter. To pick and adjust colours visually, try Color Picker, and for named web colours, HTML Color Names.
Product colours in online shops
Clothing and fabric sellers often describe colours with swatches on product pages. Sampling a colour from a photo taken in neutral daylight, rather than under warm indoor lighting, gives a far more accurate swatch. Accurate colours reduce returns from customers who received a shade different from what they saw on screen.
Paint and printed swatches
Paint makers and printing colour systems often publish approximate RGB or HEX equivalents for their colours. These help when matching a website to a shop's painted interior or printed materials, but the match is approximate, because a printed or painted surface reflects light while a screen emits it.
Converting in code
In JavaScript, each channel can be converted with toString(16) and padded to two digits with padStart, then joined after a hash sign. Padding matters: without it, a channel value of 5 becomes a single digit and shifts the whole code. Testing a few values against this converter confirms the function works.
Check readability after converting
After converting a colour for use as text or background, check it with a contrast checker against the colours it will sit beside. Colours sampled from logos and photos are chosen for appearance, not readability, and many popular brand colours need a darker variant for text.
Keep one source of truth
Once converted, store each colour in one shared place, such as a brand document or a design-token file, and copy from there. Colours retyped from memory or sampled again from different sources slowly drift, and within a year a brand can end up with several slightly different versions of its main colour.
Privacy
Conversion runs in your browser. Nothing you enter is uploaded or stored.
Frequently asked questions
Why do RGB values stop at 255?
A channel uses one byte of memory, which allows 256 levels numbered 0 to 255. Put the three channels together and you get 24 bits, the same information a six-character HEX code holds, enough for about 16.7 million distinct colours.
What happens if I type a number above 255?
The tool lowers it to 255 and a short message explains the change. That way the preview and the resulting code always show a colour that can really exist, rather than one built from an invalid value.
How is transparency written in a HEX code?
Two further characters are appended, making eight altogether. An alpha of 0.5 works out at roughly 80 in hexadecimal, which means red at roughly half opacity is written #FF000080.
Can every browser read HEX codes that include transparency?
All current browsers do. If a project must support very old browsers, use the rgba form instead, which has been understood for much longer and gives exactly the same result.
Will my printer reproduce the same colour?
Not exactly. Screens create colour by mixing red, green and blue light, while printers mix cyan, magenta, yellow and black ink. Bright screen colours often print duller, so print work needs a proper conversion.
Why would I press the random button?
It sets each channel to a random value, which is a quick way to stumble on combinations you would not have chosen deliberately, useful when you are stuck while building a palette.