RGB to HEX Converter
Convert RGB values to a HEX color code instantly in your browser. Enter red, green and blue and get the matching hex string — free and private.
HEX
—
RGB
—
HSL
—
How to convert RGB to HEX
- Type an RGB value into the box above, e.g.
rgb(59, 130, 246). - The HEX and HSL values update live as you type.
- Copy the HEX value straight out of the result card.
How the conversion works
Each RGB channel is a decimal number from 0–255. Converting to hex means writing each channel as a 2-digit base-16 number and concatenating them: rgb(59, 130, 246) becomes #3b82f6, since 59 is 3b, 130 is 82 and 246 is f6 in hexadecimal.
Where you'll need this
- Turning a color you picked or sampled as RGB into a hex string for CSS, SVG fills or a design tool.
- Copying colors from an image-editing tool's RGB readout into a stylesheet.
- Standardizing a codebase on hex colors when some values arrive as RGB tuples.
Related tools
- HEX to RGB converter — go the other way.
- HEX to HSL converter — get hue, saturation and lightness instead.
- Color contrast checker — check WCAG accessibility between two colors.
Frequently asked questions
- How do I convert RGB to HEX?
- Convert each of the red, green and blue values (0–255) to a 2-digit base-16 number, then join them with a leading #. For example, rgb(59, 130, 246) becomes 3b, 82, f6 — or #3b82f6.
- What format should I type the RGB value in?
- Use CSS function syntax, e.g. rgb(59, 130, 246) or rgba(59, 130, 246, 0.5) — the alpha value is accepted but ignored, since hex colors here have no alpha channel.
- Why does my RGB value show an error?
- Each channel must be a whole number between 0 and 255. Values outside that range, or text that isn't in rgb(r, g, b) form, will not parse.
- Is HEX or RGB better to use?
- Neither is "better" — they represent the same color. HEX is more compact and common in CSS and design tools; RGB is more explicit and easier to read as separate channel values, which some code and APIs prefer.
- Does this tool round the RGB values?
- Whole-number channel values convert exactly with no rounding error, since each channel maps directly to a 2-digit hex pair.
- Is my color data sent to a server?
- No. The conversion is plain arithmetic that runs entirely in your browser with JavaScript — nothing is uploaded or logged.