RGB to HEX Converter
Color Picker · developer
Convert RGB values to HEX with a fixed input and output format, live preview of the conversion line, and copy-ready results. All processing runs locally in your browser.
Calculator
From: RGB (red, green, blue)
To: Hexadecimal (#RRGGBB)
About RGB
RGB expresses a color as three integers from 0 to 255 for red, green, and blue in the sRGB space. It matches how screens mix light.
About HEX
Hexadecimal codes pack red, green, and blue into six (or eight with alpha) base-16 digits. They are the default in CSS, design tools, and APIs.
How to convert RGB to HEX
Enter a valid RGB value in the calculator. The tool follows the pipeline below: parse your input, hold the color as sRGB (with alpha when relevant), then format the result as HEX.
Accepted shapes include CSS-like functions (e.g. rgb(...), hsl(...)) and compact comma-separated numbers where appropriate. Hex may include or omit the leading #.
Conversion procedure
- Parse RGB: accept either a CSS function rgb(r, g, b) or three numbers separated by commas. Whitespace is ignored. Each of R, G, B must be an integer or decimal within 0–255; values outside that range are treated as invalid input.
- Resolve to internal sRGB: the three integers are taken as R, G, B directly in sRGB. Alpha is fixed at 1 because plain RGB carries no transparency in this tool.
- Build HEX: each of R, G, B is clamped to 0–255, rounded to an integer, and written as two uppercase hexadecimal digits. The calculator concatenates them as #RRGGBB. If the internal alpha is less than 1 (from RGBA or 8-digit hex input), two more hex digits are appended so the string becomes #RRGGBBAA; otherwise the six-digit form is used.
- Finalize: the result string is what you copy from the calculator. The line under the fields summarizes the path in short form (HEX ← sRGB ← RGB). Rounding is intentional so values read like typical CSS; tiny differences versus other apps can still appear because of integer hue, saturation, lightness/value, or ink percentages.
Example
Input (RGB): 52, 152, 219
Output (HEX): #3498DB
Summary
This page converts RGB input into HEX output. The numbered “Conversion procedure” above is the full breakdown: validation and parsing, conversion to a single internal sRGB (+ alpha) sample, derivation of HEX coordinates from that sample, and final rounding to the strings you see in CSS-oriented tools. The same pipeline runs in your browser as you type.
Relationship context
RGB (red, green, blue) and Hexadecimal (#RRGGBB) are different ways to describe the same sRGB color (except CMYK, which is an approximate ink model). Converting RGB → HEX does not change the underlying color within the limits of each notation; it only changes how numbers are written.
Example conversions
Sample RGB values and the matching HEX output using the same rules as the calculator.
| RGB input | HEX output |
|---|---|
| 0, 0, 0 | #000000 |
| 255, 255, 255 | #FFFFFF |
| 231, 76, 60 | #E74C3C |
More color format converters
Other dedicated pages (fixed input and output types). Open the Color Picker for the full list.
- CMYK to HEX ConverterCMYK to HEX
- HSL to HEX ConverterHSL to HEX
- HSV to HEX ConverterHSV to HEX
- RGB to CMYK ConverterRGB to CMYK
- RGB to HSL ConverterRGB to HSL
- RGB to HSV ConverterRGB to HSV
- RGB to RGBA ConverterRGB to RGBA
- RGBA to HEX ConverterRGBA to HEX
- CMYK to RGB ConverterCMYK to RGB
- HEX to CMYK ConverterHEX to CMYK
- HEX to HSL ConverterHEX to HSL
- HEX to HSV ConverterHEX to HSV