RGB to HEX Converter
This converter turns an RGB color into its six-digit hex code as you type. Paste a full CSS value like rgb(59, 130, 246) or just the bare 59, 130, 246 triple, and the matching hex appears beside a live color swatch. A small panel below also shows the same color written as HEX, RGB and HSL so you can copy whichever notation your project needs.
How to convert RGB to HEX
- Type or paste your color into the RGB color field, either as rgb(255, 0, 0) or as a plain 255,0,0 triple.
- Check the color swatch to confirm the shade looks right.
- Read the six-digit hex code shown under the HEX label.
- Click the copy button next to it to put the hex value on your clipboard.
- Paste the code into your CSS, design tool, or the HEX, RGB and HSL panel for the other notations.
Examples
Pure red
rgb(255, 0, 0)
#ff0000
Tailwind blue-500
rgb(59, 130, 246)
#3b82f6
Mid gray from a bare triple
128,128,128
#808080
Frequently asked questions
What is the difference between RGB and HEX?
They describe the same color in different notations. RGB lists three channels (red, green, blue) from 0 to 255, while HEX packs those same three channels into a six-digit hexadecimal string like #3b82f6. Converting between them never changes the color, only how it is written.
What input formats does this accept?
Both the CSS rgb(...) form and a plain comma-separated triple work, so rgb(255, 0, 0) and 255,0,0 produce the same #ff0000. The parser simply reads the first three numbers it finds, which makes it forgiving of extra spaces and surrounding text.
What range do RGB values use?
Each channel is a number from 0 to 255, where 0 is none of that color and 255 is full intensity. Values below 0 or above 255 are rejected as invalid, and anything with fewer than three numbers is reported as an invalid RGB color.
Can I enter decimal channel values?
Yes, but hex has no fractional channels, so a decimal like 59.6 is rounded to the nearest whole value before it is written as two hex digits. For predictable results, enter whole numbers from 0 to 255.
How do I use the hex code in CSS?
Paste the hex value directly into any color property, such as color: #3b82f6 or background: #ff0000. Hex codes work everywhere CSS expects a color, including SVG fills and most design and diagram tools.
Why are the letters in the hex code lowercase?
Hex colors are case-insensitive, so #FF0000 and #ff0000 are identical. This tool outputs lowercase by convention, which is the most common style in CSS and keeps diffs and search tidy.
Does it output shorthand three-digit hex?
No. It always writes the full six-digit form. That keeps the output consistent, and only a few colors, such as #ff0000, could be shortened anyway. A six-digit code is valid everywhere a three-digit one is.
What are the extra HEX, RGB and HSL boxes for?
Below the main result the tool restates the same color in all three notations at once. That is handy when a stylesheet mixes formats or when you want the HSL version to nudge lightness or saturation without leaving the page.
Is my color data uploaded anywhere?
No. The conversion happens entirely in your browser, so the colors you enter never leave your device. The same pure engine also powers the optional API for automated use.
Learn more
- How an RGB triple becomes a hex code
The math that turns red, green and blue values from 0 to 255 into a six-digit hex color, digit by digit, with worked examples.
Related tools
HEX to RGB
Convert HEX color codes to RGB online. Paste a hex value like #ff0000 and get the rgb() string instantly. Supports shorthand. Runs in your browser.
RGB to HSL
Convert RGB colors to HSL instantly. Paste an rgb() value and get hue, saturation and lightness, with a live preview. Runs in your browser.
Air Fryer Converter
Convert any conventional oven recipe to air fryer settings. Lower the temperature by 25 F and cut the cook time by about 20 percent automatically.
Baker's Percentage Calculator
Turn a bread formula into grams with baker's percentages. Flour is 100 percent, enter water, salt and yeast percents to get weights and hydration.
Baking Pan Converter
Swap one baking pan for another and scale the batter to fit. Compares pan areas for round, square and rectangular pans and gives a batter scale factor.
Binary to Decimal
Convert binary to decimal online. Paste any binary number, with or without spaces, and get the exact base-10 value instantly. Runs in your browser.