Home›Developer Tools›HEX to RGB Converter

HEX to RGB Converter

Any colour in, every format out — with a live swatch and contrast check.

Also searched as: rgb to hex · convert hex to rgb · hex code to rgb

HEX to RGB, RGB to HEX, HSL and more

Type a colour in any format — #1f7a4d, rgb(31, 122, 77), hsl(150, 60%, 30%) or a CSS name like tomato — and get every other format with a live swatch: HEX, RGB, RGBA, HSL, CMYK (for print), the nearest CSS colour name, and the white/black text contrast ratio for accessibility.

How HEX and RGB relate

A HEX code is three pairs of hexadecimal digits for red, green and blue: #1f7a4d = rgb(31, 122, 77) because 1f = 31, 7a = 122, 4d = 77. Shorthand #fff expands to #ffffff. HSL describes the same colour as hue (0–360°), saturation and lightness, which is easier for making lighter/darker variants.

Designers also like the aspect ratio calculator and image resizer.

Frequently asked questions

How do I convert HEX to RGB?

Split the 6 digits into pairs and convert each from hexadecimal to decimal — or paste the code above and read the RGB value.

What is the HEX code for white and black?

#ffffff is white and #000000 is black.

What is the contrast ratio shown?

The WCAG contrast of the colour against white and black text — aim for 4.5:1 or higher for normal text.

More free tools

JSON Formatter & ValidatorBeautify, minify and validate JSONDeveloper ToolsXML FormatterPretty-print and validate XMLDeveloper ToolsBase64 Encode / DecodeText ↔ Base64, UTF-8 safeDeveloper ToolsURL Encode / DecodePercent-encode or decode any URL or query stringDeveloper ToolsRegex TesterTest JavaScript regular expressions with live matchesDeveloper ToolsWord to HTML ConverterPaste from Word or Docs, get clean HTMLDeveloper Tools