HEX to RGB Converter

Convert a HEX colour code to RGB and HSL.

HEX to RGB Converter tool

Accepts 3, 4, 6 or 8 digits. The leading hash is optional.

Converted values

Channels

0
Red
0
Green
0
Blue
1
Alpha

About the HEX to RGB Converter

Brand guides, design files and websites give colors as HEX codes, while many apps, design tools and code libraries expect RGB values. This hex to RGB converter unpacks a code into its red, green and blue channels and shows the HSL equivalent and copy-ready CSS: #2453E6 is rgb(36, 83, 230). Three-digit shorthand such as #09C is expanded automatically, and an eight-digit code with transparency is handled too, so the result matches what browsers display. A live swatch confirms you have the right color before you paste it anywhere. To go the other way, use the RGB to HEX Converter, and for print, the RGB to CMYK Converter.

Every common length of HEX code is understood. The three-digit short form doubles each digit, so #f90 is the same colour as #ff9900. Six digits is the standard form. Four- and eight-digit codes carry a transparency value, which the converter expresses as an opacity figure in the rgba result. Typing the # sign at the start is optional.

RGB is the format to reach for when you need transparency or when a charting library, game engine or animation script expects three separate channel numbers. HSL is the better choice when the colour itself needs adjusting, because changing its lightness or saturation by hand is far more predictable than nudging three independent channels. When you need transparency, the same colour can carry an alpha value in CSS, written as rgb(255 0 0 / 50%) or in the older rgba() form.

How to use the HEX to RGB Converter

  1. Enter the HEX codeType or paste it, with or without the # sign.
  2. Let it validateWrong characters or an unusual length produce a clear message instead of a misleading colour, so mistakes copied from a document are caught early.
  3. Read the resultsRGB and HSL values appear next to a live swatch of the colour.
  4. Copy what you needEvery format has its own copy button.

HEX to RGB Converter features

  • Three, four, six and eight digit HEX codes accepted
  • The # sign is optional
  • Results as rgb, rgba, hsl and hsla
  • Live swatch of the converted colour
  • Clear message for malformed codes
  • One-click copy for every format

Common uses

  • Turning a brand HEX colour into RGB for a CSS gradient
  • Giving an existing solid colour some transparency
  • Moving colours from a design file into code
  • Getting HSL numbers so a brand colour can be made paler in even steps
  • Checking that a HEX value in a specification is written correctly

HEX to RGB in practice: an Independence Day banner overlay, modern CSS syntax, Office apps, Android colour order, LEDs and quick brightness checks

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

HEX codes are the language of the web, but many tools and devices expect red, green and blue as separate numbers: presentation software, mobile app code, LED controllers and image editors. This guide converts the flag green for a banner overlay and covers modern CSS syntax, Office apps, the reversed alpha order in Android code, LED projects and a quick way to judge whether a colour needs white or black text.

A worked example: a banner overlay

An Independence Day banner places a photo behind a semi-transparent green panel. The dark green commonly used for Pakistan's flag, #01411C, converts to rgb(1, 65, 28). Adding an alpha value gives rgba(1, 65, 28, 0.8), a panel that is 80 percent opaque, letting the photo show faintly through while white text on top stays readable.

Modern CSS syntax

Current CSS accepts a space-separated form with the alpha after a slash, such as rgb(1 65 28 / 80%). It is equivalent to the older comma form and supported by all modern browsers. Use whichever form your codebase already uses, so stylesheets stay consistent.

Office and presentation apps

Custom colour dialogs in Word, PowerPoint and similar apps traditionally ask for red, green and blue values, although newer versions also accept HEX codes. Entering the exact RGB values from a brand guide keeps slides and documents consistent with the website, instead of choosing a close match by eye.

Alpha order in Android code

CSS writes eight-digit colours with alpha last, as #RRGGBBAA, while Android and some other platforms write colour integers with alpha first, as 0xAARRGGBB. The flag green at full opacity is 0xFF01411C in Android code. Copying an eight-digit CSS colour into Android without reordering produces a completely different colour.

LED projects

RGB LEDs in Arduino and similar projects take brightness values from 0 to 255 for each channel, exactly matching the RGB numbers from a HEX code. Converting a brand or theme colour lets a project's lights match it, although LEDs often look more saturated than screens, so some adjustment by eye may be needed.

A quick brightness check

A rough measure of how bright a colour looks multiplies red by 0.299, green by 0.587 and blue by 0.114 and adds them. For the flag green this gives about 42 out of 255, clearly dark, so white text suits it. For a reliable accessibility decision, use a contrast checker, which applies the official formula.

Shorthand and validation

Three-digit codes double each digit, so #FC0 means #FFCC00. A valid code contains only the digits 0 to 9 and the letters A to F. Codes copied from documents sometimes contain the letter O instead of zero, which makes them invalid; the converter flags these immediately.

Image editing

Image editors show colours as RGB values in their colour pickers. Converting brand HEX codes to RGB before editing photos or graphics lets you enter exact values, so a banner made in an image editor matches buttons and headings made in CSS.

Common mistakes

  • Copying eight-digit CSS colours into Android code without reordering.
  • Typing the letter O instead of zero in codes.
  • Choosing text colours by eye instead of checking contrast.
  • Mixing comma and space syntax inconsistently in one stylesheet.

Related tools

To convert in the other direction, use RGB to HEX Converter. For HSL, CMYK and more, try Color Converter, and to check text colours on the result, Color Contrast Checker.

Converting in a spreadsheet

To convert a column of HEX codes in Excel or Google Sheets, apply HEX2DEC to each pair of digits, for example HEX2DEC of the two characters starting at position 2 for red, position 4 for green and position 6 for blue. It is handy when preparing brand colour lists for printers or developers who need decimal values.

Canvas and image processing

When a script reads pixels from an image using the canvas element, each pixel arrives as four numbers from 0 to 255: red, green, blue and alpha. Converting brand colours to the same form lets a script check whether an uploaded image uses the right colours, or count how much of an image is close to a given shade.

Transparency in emails

Some email programs, including desktop versions of Outlook, ignore rgba transparency and may show no background at all. Give important elements a solid background colour first, then an rgba value after it, so clients that understand transparency use it and others fall back to the solid colour.

Colours in charts

Charting libraries accept colours in HEX or RGB. Converting the brand palette once and storing it as a list keeps every chart in reports and dashboards consistent with the website, rather than each chart using the library's default colours.

Converting a whole stylesheet

When tidying an older stylesheet, converting its scattered HEX codes into a short list of named custom properties makes future changes far easier. Collect every colour, convert and group near-duplicates, then replace each raw code with its variable, checking pages as you go.

Privacy

Conversion runs in your browser. Nothing you enter is uploaded or stored.

Further reading: HEX, RGB and HSL Colour Codes, and Accessible Contrast.

Frequently asked questions

Which characters and lengths are allowed in a HEX code?

After the optional # sign it may use only digits and the letters A to F, and it must be three, four, six or eight characters long. Anything else, such as a typing slip that includes a G or an O, is rejected with a message.

What are the last two digits of an eight-digit code?

They hold the alpha channel, which sets opacity from 00, fully transparent, to FF, fully solid. In the rgba and hsla results the converter turns that pair into an opacity figure, where 1 means solid and 0.5 means half see-through.

Are #FFF and #FFFFFF the same colour?

Yes. In the short form each digit is doubled, so #FFF becomes #FFFFFF and #F90 becomes #FF9900. A colour can only be shortened that way when both digits of each pair are the same.

Does it matter whether I use capital letters in HEX?

No. Upper-case and lower-case letters mean exactly the same thing to browsers and design tools. Many teams pick one style for consistency, but both produce identical colours.

When would HSL be more useful than RGB?

When you want to change a colour in a controlled way. Push the lightness up for a paler version, pull it down for a deeper one, or reduce saturation for a softer, greyer colour, all while the basic hue stays the same.

Can I convert a whole palette at once?

This tool handles one code at a time so that each value can be checked properly. For a palette, convert the colours one after another and copy each result as you go.