Skip to content

HEX to RGB

Convert a hex color to RGB.

Input
Output

No result

About HEX to RGB

HEX to RGB turns a hexadecimal color into the decimal red, green and blue channels that the rgb() function expects. Feed it #4F46E5 and it returns rgb(79, 70, 229) — the same color written the way CSS, canvas and most graphics APIs want to read it.

The conversion is mechanical: each of the three hex byte pairs is read as a base-16 number in the range 0 to 255. Three-digit shorthand such as #f0c is expanded first by doubling every digit, so it becomes #ff00cc before the channels are read. The output is opaque and uses plain integers, which makes it convenient to drop into a style rule, a canvas fillStyle or an inline SVG attribute when all you have is the hex value from a design file.

One boundary is worth stating: this tool reports only r, g and b. An eight-digit hex with an alpha channel is accepted but its transparency is discarded, so if you need a semi-transparent color you want the Color Opacity tool instead.

The output is a single notation, and it stays in the decimal channel form. There is no percentage variant, no modern space-separated syntax, and no choice between the comma and slash styles, so a house convention that differs from the plain comma form has to be adjusted after copying. The reverse direction is not offered here — rgb() values are read by a separate tool — and the page does not report the colour's name, its hue family or its luminance, all of which are things you might want alongside a channel breakdown for accessibility work. Named-colour input is not accepted either, so a value written as a word needs converting to hex before it goes in.

How to use HEX to RGB

  1. 1 Paste the hex color, with or without the leading hash, into the field.
  2. 2 Read the rgb() value, which is recalculated on every keystroke.
  3. 3 Drop the result straight into a style rule, a canvas fillStyle or an SVG fill attribute.

Frequently asked questions

Does the leading # matter?

No. The parser trims and lowercases the input, so #4f46e5 and 4f46e5 behave identically. It also accepts three-digit shorthand and expands it for you.

What range does each channel use?

0 to 255. A hex byte pair FF is the decimal value 255 and 00 is 0, so the three channels together describe about 16.7 million opaque colors.

Why has my transparency disappeared?

This tool returns only rgb(), which has no alpha component. An eight-digit hex is accepted, but just the red, green and blue channels are reported. If you need transparency, use the Color Opacity tool to build an rgba() string.

Free, online, and private

Free to use

HEX to RGB is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How HEX to RGB behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Accepted input #rgb, #rgba, #rrggbb and #rrggbbaa, with or without the leading #
Output rgb(r, g, b) with each channel 0–255
Shorthand handling #f00 expands to 255, 0, 0

Compiled from the implementation of this tool and checked against it by itoolnet.

What HEX to RGB does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • This converts one format in one direction. To go the other way use RGB to HEX, and for a full five-format breakdown from a single input use Color Converter.
  • The alpha channel is discarded. A four- or eight-digit hex value is accepted and converted, but the result is an opaque rgb() triple with the transparency dropped.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to HEX to RGB with the snippet below. It is free, runs entirely in your browser, and needs no signup.