Shard Tools

Hex to RGB

Convert a hex colour to RGB in your browser, accepting both three and six digit forms.

Maintained by Roshan.

Use Hex to RGB

Converts hex colour to rgb in this tab, with nothing sent anywhere.

Runs entirely on your deviceThe conversion happens in this browser tab. Nothing you type is uploaded, logged or stored, which is worth knowing for anything you would not paste into a search box.

During the latest release check, #3366CC returned the RGB channels 51, 102, 204 in the browser. The result was checked from the rendered output rather than inferred from the page copy.

Explore general converters

Find related browser-local tools for nearby tasks without starting another search.

Browse all general converters

About Hex to RGB

Hex and RGB are two ways of writing the same colour, and converting between them is a constant small task in design and front-end work. A hex code packs the three colour channels into six digits - two for red, two for green, two for blue - which is compact and what CSS and design tools use by default. RGB spells the same three channels out as numbers from 0 to 255, which is the form you need when a value has to go into code that does arithmetic on colours, into a graphics API, or into a tool that only takes decimal channels. This converter reads a hex code, including the three-digit shorthand where each digit is doubled, and returns the equivalent RGB, so a colour picked in one place drops straight into another.

Using Hex to RGB

  1. A leading hash is optional and stripped, so a code copied with or without it works.
  2. The three-digit shorthand is expanded by doubling each digit, so a short code like #3bf becomes the full six-digit value.
  3. Each pair of hex digits is read as one channel and converted to its decimal value between 0 and 255.
  4. The result is written in the standard rgb(r, g, b) form that CSS and most tools accept.
  5. An input that is not a valid three or six digit hex colour is refused with a message.

Where hex to rgb helps

Moving a colour into code

A hex value from a design tool converts to the RGB channels a graphics library or a calculation needs.

Building an rgba value

Convert to rgb first, then add the alpha you want - the channels are the hard part.

Before you use the result

Questions about Hex to RGB

Does it accept shorthand hex?

Yes. A three-digit code like #3bf is expanded by doubling each digit before conversion.

Is the hash required?

No. It is optional and stripped, so codes with or without it work.

What about an alpha channel?

Eight-digit hex with alpha is not handled here. Use an opaque six-digit code, or a colour tool that supports alpha.

Does the colour change?

No. Hex and RGB are two notations for the same colour; only the way it is written changes.

Related tools

RGB to Hex

Convert an RGB colour to a hex code in your browser, from any common RGB format.

Hex to HSL

Convert a hex colour to HSL in your browser, the model that makes colours easy to adjust.

Text to Hex

Convert text to hexadecimal in your browser. Each character becomes its UTF-8 bytes in hex.