RGB to HEX Converter

RGB to HEX: rgb(244, 67, 54) = #F44336. See the formula worked step by step, a reference table, and our test of every RGB value.

How to use RGB to HEX

  1. 1Type the red, green and blue values (0–255).
  2. 2Copy the six-digit HEX code.
  3. 3Add two more digits yourself if you need alpha (#RRGGBBAA).

Features

  • One exact code for every RGB colour
  • Material Design 500 colours as a reference
  • Lossless: verified on all 16.7 million colours

How RGB to HEX conversion works

Going from RGB to HEX is pure notation: each 0–255 channel becomes two base-16 digits. Nothing is calculated or rounded, so every RGB colour has exactly one six-digit code.

  • Take each channel (0–255).
  • First digit = channel ÷ 16, rounded down; second digit = the remainder.
  • Write the digits as 0–9 and A–F (10 = A … 15 = F); pad single digits with a leading 0.
  • Join them after a #: #RRGGBB. If every pair is a repeated digit you may shorten it to #RGB.

Worked example: rgb(244, 67, 54) to HEX

Here is the converter's own calculation for rgb(244, 67, 54), step by step. The result, #F44336, is exactly what the tool above shows for this input.

  • Red 244 = 15 × 16 + 4 → F4; green 67 = 4 × 16 + 3 → 43; blue 54 = 3 × 16 + 6 → 36.
  • Joined: #F44336.

Material Design 500 colours in RGB and HEX

The primary (500) shade of each hue in the 2014 Material Design palette.

ColourRGBHEX
redrgb(244, 67, 54)#F44336
pinkrgb(233, 30, 99)#E91E63
purplergb(156, 39, 176)#9C27B0
deep-purplergb(103, 58, 183)#673AB7
indigorgb(63, 81, 181)#3F51B5
bluergb(33, 150, 243)#2196F3
light-bluergb(3, 169, 244)#03A9F4
cyanrgb(0, 188, 212)#00BCD4
tealrgb(0, 150, 136)#009688
greenrgb(76, 175, 80)#4CAF50
light-greenrgb(139, 195, 74)#8BC34A
limergb(205, 220, 57)#CDDC39
yellowrgb(255, 235, 59)#FFEB3B
amberrgb(255, 193, 7)#FFC107
orangergb(255, 152, 0)#FF9800
deep-orangergb(255, 87, 34)#FF5722

Source: Material Design 2 colour palette (material-colors 1.2.6)

Precision test: every RGB value through the converter

Nothing can be lost here. We converted all 16,777,216 RGB colours to HEX and back: 100% came back identical, and 16,777,216 distinct codes were produced, one for every colour.

Method: every whole-number RGB value, through the converter's own code and back, compared on the 0–255 scale (how we test).

MeasureResult
RGB values tested16,777,216
Distinct HEX results16,777,216
Came back exactly100%
Largest change (0–255 levels)0
Average change0

Last updated · Source: Pixohub exhaustive test of lib/color-math.ts

Where you'll use RGB to HEX

Copying a colour out of code into a design tool

Browser DevTools, Python's Pillow and most screenshot pickers report rgb() or a tuple. Figma, Canva and brand guidelines mostly use HEX, so the conversion is the usual hand-over step.

Writing compact CSS and SVG

#F44336 is shorter than rgb(244, 67, 54) and is accepted by every CSS and SVG parser, including old email clients that predate rgb() with spaces.

Keys in design tokens

HEX codes are a convenient unique key for a colour in JSON tokens or spreadsheets, since every RGB colour has exactly one code (in uppercase or lowercase).

Common mistakes

  • Forgetting the leading zero: red 5 is 05, not 5; #5FF is shorthand for #55FFFF, a different colour.
  • Feeding percentages or 0–1 floats (from Swift, Unity or shaders) straight in: multiply by 255 and round first.
  • Dropping alpha silently: rgba(244, 67, 54, 0.5) needs an 8-digit code, #F4433680; a 6-digit code is fully opaque.
  • Expecting a hex value to look the same in every app: the code is exact, but apps that don't colour-manage may display it slightly differently on wide-gamut screens.

Frequently asked questions

What is rgb(244, 67, 54) in HEX?

#F44336 — Material Design's red 500. 244 = 15 × 16 + 4 → F4; 67 = 4 × 16 + 3 → 43; 54 = 3 × 16 + 6 → 36.

Do browsers accept 8-digit HEX with alpha?

Yes. #RRGGBBAA and the 4-digit #RGBA form are part of CSS Color Level 4 and work in all current major browsers.

Is RGB to HEX lossless?

Completely. We checked all 16,777,216 RGB colours: each converts to a unique HEX code and back without change.

Uppercase or lowercase HEX?

Either. CSS treats them the same. Pick one convention for your codebase so search and diffs stay clean.

More text, code & dev tools