Boneyard Tools

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

  1. Type or paste your color into the RGB color field, either as rgb(255, 0, 0) or as a plain 255,0,0 triple.
  2. Check the color swatch to confirm the shade looks right.
  3. Read the six-digit hex code shown under the HEX label.
  4. Click the copy button next to it to put the hex value on your clipboard.
  5. 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

Related tools