Skip to content
ZeroServer.tools

RGB to HEX

Convert RGB values into HEX color codes.

HEX: #00F2FER: 0G: 242B: 254Luminance: 75%
Presets & Samples
#00f2fe

Converting RGB into HEX

RGB describes a color as three channels from 0–255. To produce a HEX code, each channel is converted to a two-digit base-16 value and concatenated as #RRGGBB. Use the sliders or type exact values; the swatch and HEX output update live. Perfect for translating design-tool RGB values into CSS-ready HEX — all locally in your browser.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Converting channel values from a design tool into the hex a stylesheet uses.
  • Turning a picked RGB triplet into a token value.
  • Producing hex from values computed in code.
  • Converting a colour quoted in RGB in a specification.
  • Checking that two representations describe the same colour.

How it works in practice

A worked example

A design tool has produced channel values with decimals in them, and the stylesheet needs a hex string.

Input
R  0
G  242
B  254
Output
#00f2fe

Each channel becomes two hexadecimal digits, so the whole colour is six characters and the ordering is red, green, blue. Two hundred and forty-two is f2 and two hundred and fifty-four is fe, which is where the familiar shape of a hex colour comes from — it is nothing more than the same three numbers in base sixteen, padded so each one always occupies exactly two places and the string can be read without separators.

The edge case that catches people

Values are rounded and then clamped, in that order, and both steps lose information silently. A channel of 127.5 becomes 128 rather than 127, a channel of 300 becomes 255, and a negative one becomes zero — so a value that was outside the range comes back inside it with no complaint. The consequence worth remembering is that two different inputs can produce the same output: anything from 253.5 upwards ends as fe or ff, which makes a hex string a lossy record of a colour that arrived as decimals.

When not to use this tool

Six digits describe eight bits per channel in one particular colour space, and a good deal of design work no longer lives there. A colour picked in a wide-gamut space has values this notation cannot represent, so converting it produces the nearest thing that fits rather than the colour that was chosen — and on a display capable of showing the original, the difference is visible. Where that matters, keep the colour in a function that names its space and convert to hex only for the systems that accept nothing else.

Frequently Asked Questions

How does the conversion work?
Each channel is written as two hexadecimal digits: 0–255 becomes 00–FF. rgb(0, 242, 254) is #00F2FE. Values below 16 need a leading zero — writing `F` instead of `0F` shifts every following digit and is the single most common hand-conversion bug.
Is hex case-sensitive?
No — #FFF and #fff are identical, and CSS accepts either. Upper case is the more common convention in design tools, lower case in CSS codebases. Pick one for a project so a diff never shows a change that is not one.
What is the eight-digit form?
#RRGGBBAA, with the last pair as alpha: #00F2FE80 is roughly 50% opaque. It is supported in every current browser. The four-digit #RGBA shorthand exists too, on the same repeat-each-digit rule as #RGB.
Why does hex exist if rgb() is clearer?
History and compactness — it comes from the era when a colour was a byte triple written the way memory was dumped. It survives because it is one token to copy, impossible to get half-pasted, and every design tool speaks it.
Is hex limited to sRGB?
Yes, and that is now a real limit. Wide-gamut displays can show colours outside sRGB that no hex value can name, which is why modern CSS added `color(display-p3 …)` and `oklch()`. For everyday interface work sRGB remains the safe default.
What happens to a value above 255 or a decimal?
CSS clamps out-of-range channels to 0-255 and rounds fractional ones, so `rgb(300, -5, 12.7)` resolves to `#FF000D`. The clamping is silent, which is why a computed colour that looks wrong is worth converting to check.

Common errors and gotchas

  • Omitting the leading zero on a channel below 16, which shifts the whole string.
  • Losing alpha, which needs the eight-digit hex form to survive.
  • Assuming values are 0-255 when a source used 0-1 floats, which is a factor of 255 out.
  • Mixing upper and lower case where a format or a linter specifies one.
  • Rounding a computed float channel before converting, which shifts the colour visibly at low values.

Related Design & CSS tools

Private & free — this tool runs entirely in your browser.

KinstaFast managed hosting — up to $500 + 10% recurring.affiliate