RGB & Hex Color Converter

How to use 3 steps
  1. Enter a HEX code or RGB value.
  2. Press Convert Color Code.
  3. Copy the format you need.
Color Format Conversions

How this tool works

A hex colour code converts to its red, green and blue components, with a swatch of the colour and a ready-to-paste CSS declaration.

A hex code is three pairs of hexadecimal digits, one per channel, each holding a value from 0 to 255. Three-digit shorthand is expanded first by doubling each digit, so #f0a becomes #ff00aa — that expansion is exact, which is why the shorthand exists. A missing leading hash is added rather than treated as an error. Anything that is not a valid hexadecimal pair reads as zero, so a malformed code produces a dark colour rather than a warning, and the swatch is the quickest way to notice.

Working with colour values

  • The swatch is the error check: an invalid code parses as zero rather than failing, so a colour that looks wrong usually means a typo in the input.
  • Shorthand expansion doubles digits: #abc is #aabbcc, not #a0b0c0. Only colours whose channel pairs happen to repeat can be written in shorthand at all.
  • Hex and RGB are the same numbers: one is base sixteen and the other base ten. Neither is more precise; use whichever your tooling expects.
  • Contrast is not visible in the code: two colours can look distinct on your screen and still fail accessibility contrast requirements. Check the ratio rather than trusting the swatch.

The swatch is the actual error check

An invalid hexadecimal character in the [msm_tool slug="rgb-hex-converter"] reads as zero rather than raising an error, so a mistyped code produces a dark colour instead of a warning message — the swatch shown alongside the numbers is the fastest way to notice something went wrong, since a colour that looks unexpectedly dark almost always means a typo sitting somewhere in the input.

Shorthand expansion doubles digits exactly

Three-digit shorthand is expanded by doubling each digit, so `#f0a` becomes `#ff00aa` precisely rather than approximately — which is also why only colours whose channel pairs happen to repeat can be written in the shorter form at all. `#abc` expands to `#aabbcc`, never to something like `#a0b0c0`.

Hex and RGB are the same numbers, not different levels of precision

A hex code is three pairs of hexadecimal digits, one per channel, each holding a value from 0 to 255 — identical to the values RGB expresses in base ten. Converting between the two representations is exact in both directions and loses nothing whatsoever; the choice between them comes down entirely to whatever a given piece of tooling expects to read.

A colour looking distinct is not the same as passing contrast

Two colours can appear clearly different on a screen and still fail accessibility contrast requirements when actually measured, because visual distinctiveness and a formal contrast ratio are simply not the same test. The code and the swatch here show what a colour is, not whether it works against another colour for anyone reading text set in it.

What it does not handle

Eight-digit hex codes carrying a fourth, alpha channel for transparency are not parsed here — only the standard six-digit and three-digit shorthand forms are read, so a code with transparency information will need a different tool or a manual split of the extra pair.

Frequently Asked Questions

Specific to the RGB & Hex Color Converter. Broader questions about this category are answered on the category page.

Three pairs of hexadecimal digits giving the red, green and blue components in that order, each from 00 to FF — zero to 255 in decimal. #FF0000 is full red with no green or blue.
Because three-digit shorthand doubles each digit to produce the full six, so it can only express colours where both digits of every pair are the same. #ABC expands to #AABBCC exactly.
No. They are the same values in different bases. A conversion between them is exact in both directions and loses nothing.
Invalid hexadecimal characters read as zero rather than raising an error, so a typo silently darkens the colour. Compare the swatch against what you expected and check the input for stray characters.
No. Eight-digit hex codes carrying an alpha channel are not parsed here — only the six-digit and three-digit forms.

Subscribe to receive notifications about new tools, features, and productivity tips.