Convert RGB color values to a hex code instantly. Learn the RGB-to-hex math and copy clean six-digit hex codes for your HTML and CSS.
Controls transparency - 0% is fully transparent, 100% is fully opaque
Solid (100%)
With Opacity (100%)
Complementary colors are opposite each other on the color wheel, creating high contrast and vibrant looks. Perfect for making elements stand out.
Click on the wheel to change hue
You have three numbers and you need six characters. The eyedropper in your screenshot tool reported 168, 85, 247. A chart library handed back rgb(16, 185, 129). A colleague read channel values off a slide over a call. None of that is what a stylesheet, an HTML attribute or a design token file wants to store, so it has to be compacted into #RRGGBB.
This page is where you produce that code. Drag the picker square, work the hue wheel, or switch to the Sliders tab and set red, green and blue on their own 0–255 tracks — each slider's track is tinted to show what moving that one channel would do while the other two stay put, which makes matching a target colour much faster than guessing. The HEX field updates live, and the copy button next to it puts the finished code on your clipboard.
Nothing leaves the browser. The arithmetic is a few lines of JavaScript running in your tab: no file is uploaded, no colour is logged, and the swatches you save live in your own browser storage. Client-side is also why the output is instant — there is no request to wait on between moving a slider and reading the code.
Each channel is a whole number from 0 to 255, and each becomes exactly two base-16 digits. The conversion is one division:
09, never 9.That leading zero is the single most common hand-conversion bug. Drop it and every character after it shifts one place left, which silently turns your code into a different colour rather than an error you would notice.
| Decimal | Hex digit | Decimal | Hex digit |
|---|---|---|---|
| 0–9 | 0–9 | 13 | D |
| 10 | A | 14 | E |
| 11 | B | 15 | F |
| 12 | C | 16 | 10 (carries) |
Three divisions, joined end to end.
2 and 5 → 25.6 and 3 → 63.E, eleven is B → EB.Concatenate in red-green-blue order and prefix a hash: #2563EB. Order matters and there is no separator to protect you, so a transposed pair produces a perfectly valid code for the wrong colour. When you have converted by hand, paste the result back in and check the swatch matches what you expected before committing it.
| rgb() | Hex | Note |
|---|---|---|
rgb(37, 99, 235) | #2563EB | The worked example above |
rgb(16, 185, 129) | #10B981 | Red 16 carries, giving 10 |
rgb(244, 63, 94) | #F43F5E | Blue 94 = 5 remainder 14 → 5E |
rgb(9, 9, 11) | #09090B | Leading zeros are mandatory |
rgb(255, 255, 0) | #FFFF00 | Two channels maxed, one off |
rgb(255, 102, 0) | #FF6600 | Shortens to #F60 |
Plenty of tools do not report 0–255 integers, and converting the wrong scale is a quiet way to produce a colour that is close but not right.
rgb(100%, 40%, 0%)) multiply by 2.55. Forty percent is 102, giving #FF6600. Multiplying by 2.55 rather than 2.5 matters: 2.5 would give 100, or #FF6400, a visibly different orange at the extremes.Any of those can leave you with a fraction, and hex has no room for one. This tool rounds to the nearest whole number, with halves rounding up, so 127.5 becomes 128 and produces 80. That is a real, if tiny, loss: the code you get back is the nearest expressible colour, not the exact one your source described. It is invisible to the eye but worth knowing if you are comparing a generated code against a reference value and find it off by one.
This tool always writes the full six-digit form in uppercase with a leading #. Two shorter or longer forms exist and are worth a word.
Three-digit shorthand is only available when every pair happens to be a doubled digit. #FF6600 qualifies and can be written #F60; #FF6601 does not and cannot be shortened at all. The saving is three characters, which is why most codebases have stopped bothering — a build step gzips it away, and a consistent six-digit form is easier to search for.
Eight-digit hex appends a fourth pair for alpha. This page does not emit it. Set transparency with the opacity slider and copy the rgba() or hsla() line instead, where alpha appears as a 0–1 decimal. That is the form CSS has supported longest and the form most design tools will accept without complaint.
Modern CSS treats #2563EB and rgb(37, 99, 235) as interchangeable in any property that takes a colour, so choosing between them is a house-style decision, not a technical one. A handful of places do insist on hex:
<input type="color"> only accepts a seven-character #rrggbb value. No shorthand, no rgb(), no alpha — anything else is discarded and the control falls back to black.<meta name="theme-color"> tag and web app manifests are conventionally written as hex, and some consumers parse nothing else.The reverse case — needing the channels back out of a code someone gave you — is the job of the hex to RGB converter.
Producing one code is rarely the whole task; usually you need a hover state and a pressed state to go with it. The Color Tools row on this page gives you Lighten, Darken, Saturate, Desaturate, Complement, Invert and Grayscale, each applied to the current colour. Lighten and Darken step the HSL lightness by ten points and leave hue and saturation alone, so pressing Darken once gives you a defensible hover shade of the same colour rather than a different colour; press it again for a pressed state, and copy the hex at each stop. Because those steps route through HSL and round to whole numbers, repeated presses drift slightly — generate each stop from the base colour rather than compounding a long chain if you need the ramp to be exactly reproducible.
Does converting to hex lose anything? Not if you start from integer channels — hex is the same three bytes written differently, so it round-trips exactly. Loss only enters when your source had fractions, percentages or more than 8 bits per channel, as above.
Should the letters be uppercase or lowercase? Neither is more correct; CSS is case-insensitive here. This tool emits uppercase. Pick one and enforce it with a linter, because mixed case in a codebase defeats find-and-replace when a brand colour changes.
Why does my code look different in print? Hex describes light being emitted, and it is interpreted as sRGB. Print is ink on paper, described by CMYK, and no automatic conversion between them is faithful — the CMYK line on this page is a useful approximation for a rough check, not a value to hand a printer.
Can I share the exact colour I landed on? Yes. Press Share Color to copy a link that reopens this page on the same colour, so a reviewer sees what you saw without you pasting a code into chat and hoping they paste it back correctly.
Convert each channel (0–255) to a two-digit hexadecimal number. Divide the value by 16 for the first digit and use the remainder for the second, writing 10–15 as A–F. Pad single digits with a leading zero, then join the three pairs after a hash.
It is #3B82F6: 59 becomes 3B, 130 becomes 82, and 246 becomes F6. The converter produces this result automatically.
Hex is base-16, so it needs six extra symbols beyond 0–9. The letters A through F represent the values 10 through 15. A pair like FF therefore equals 255, the maximum for a channel.
Yes. Hex channels are whole numbers from 0 to 255, so round any fractional RGB values first. Values out of range should be clamped to 0–255 before conversion to produce a valid code.
No. #3b82f6 and #3B82F6 represent the identical color. Uppercase is common in style guides for readability, but CSS accepts either.