RGB to hex
Each channel becomes two hex digits, zero-padded. Values are rounded to the nearest integer first.
Paste a RGB value. Other formats work too.
#00abe7Need every format at once? Open in the full picker
Worked examples
Common colors converted from RGB to hex, computed with the same engine the picker uses.
| Color | RGB | hex | Copy |
|---|---|---|---|
| Pure red | rgb(255 0 0) | #ff0000 | |
| Pure green | rgb(0 255 0) | #00ff00 | |
| Pure blue | rgb(0 0 255) | #0000ff | |
| White | rgb(255 255 255) | #ffffff | |
| Mid gray | rgb(128 128 128) | #808080 | |
| Black | rgb(0 0 0) | #000000 | |
| Interface blue | rgb(66 135 245) | #4287f5 | |
| Success green | rgb(34 197 94) | #22c55e | |
| Danger red | rgb(239 68 68) | #ef4444 | |
| Warning amber | rgb(245 158 11) | #f59e0b | |
| Editor black | rgb(30 30 30) | #1e1e1e | |
| Warm sand | rgb(233 196 106) | #e9c46a |
How the conversion works
Each channel becomes two hex digits, zero-padded. Values are rounded to the nearest integer first.
Both formats are computed from a single canonical representation (CIE XYZ with a D65 white point, held in floating point) rather than by chaining one format into the next. That matters because chained conversions accumulate rounding error, and because it means a color that cannot be represented in the target format is handled deliberately rather than by accident.
When the source describes a color outside the target's gamut, chroma is reduced in OKLCh while lightness and hue are held, following the CSS Color 4 gamut mapping algorithm. Clipping each channel independently would be simpler but visibly shifts hue on saturated colors.