Color ToolsAugust 20, 20266 min read

HEX to RGB Converter: Convert Color Codes Instantly

Learn how to convert HEX to RGB color codes and RGB to HEX values. Understand the formula, see examples, and use an online converter for instant results.

J
Jalal Khan

Color Tools · UtilityHub Blog

HEX to RGB Converter: Convert Color Codes Instantly

Why color codes matter in web development

Every pixel on a website is defined by a color code. Whether you are building a landing page, designing a mobile app, or editing a digital image, you need to translate between HEX and RGB formats — often in seconds.

A hex to rgb converter takes a hex string like #FF5733 and returns rgb(255, 87, 51). An rgb to hex converter does the reverse. Understanding both formats saves time and eliminates guesswork.

What is a HEX color code?

A HEX color code is a 6-digit hexadecimal string preceded by a hash (#). It represents the red, green, and blue channels of a color as two hex digits each.

#RRGGBB

Each pair of hex digits maps to a value between 00 (0 in decimal) and FF (255 in decimal).

HEX PairDecimal ValueMeaning
000No color (black)
80128Medium intensity
FF255Full intensity

Example breakdown

The hex code #FF5733 translates to:

ComponentHEXDecimal
RedFF255
Green5787
Blue3351

This produces a vivid orange-red color.

What is an RGB color code?

RGB stands for Red, Green, Blue — the three channels that combine to create any color on a screen. An RGB value uses decimal numbers from 0 to 255 for each channel.

rgb(red, green, blue)

For the same orange-red:

rgb(255, 87, 51)

Both #FF5733 and rgb(255, 87, 51) produce the identical color.

HEX to RGB conversion formula

Converting a HEX code to RGB requires two steps per channel:

  1. Take the two hex digits for the channel
  2. Convert them from base-16 to base-10

Manual conversion example

For #1A3F9C:

ChannelHEXCalculationDecimal
Red1A(1 × 16) + 10 = 2626
Green3F(3 × 16) + 15 = 6363
Blue9C(9 × 16) + 12 = 156156

Result: rgb(26, 63, 156)

Common hex values to memorize

HEXDecimalCommon use
000Black / no color
3351Dark shade
66102Mid-dark
99153Mid-tone
CC204Light accent
FF255Full intensity

These six values are the backbone of the CSS "safe" color palette.

RGB to HEX conversion formula

To convert RGB back to HEX:

  1. Divide each decimal value by 16
  2. The quotient becomes the first hex digit
  3. The remainder becomes the second hex digit

Conversion example

For rgb(192, 57, 43):

ChannelDecimal÷ 16QuotientRemainderHEX
Red192192 ÷ 1612 = C0 = 0C0
Green5757 ÷ 163 = 39 = 939
Blue4343 ÷ 162 = 211 = B2B

Result: #C0392B — a deep crimson red.

3-digit shorthand HEX codes

Browsers support a shorthand format where each channel is a single hex digit:

3-Digit HEXExpanded 6-Digit HEXColor
#F00#FF0000Pure red
#0F0#00FF00Pure green
#00F#0000FFPure blue
#FFF#FFFFFFWhite
#000#000000Black
#888#888888Gray

Each character is simply doubled to produce the full 6-digit equivalent.

Alpha channel (RGBA and HEX8)

Both formats support transparency through an alpha channel:

RGBA

rgba(255, 87, 51, 0.5) /* 50% transparent orange */

8-digit HEX

#FF573380 /* Same 50% transparent orange */

The last two hex digits (80 = 128) represent opacity from 00 (fully transparent) to FF (fully opaque).

Real-world conversion examples

Here is a reference table of 10 common web colors and their conversions:

Color NameHEXRGBUsage
White#FFFFFFrgb(255, 255, 255)Backgrounds, text
Black#000000rgb(0, 0, 0)Text, borders
Navy#000080rgb(0, 0, 128)Headers, links
Crimson#DC143Crgb(220, 20, 60)Alerts, accents
Forest Green#228B22rgb(34, 139, 34)Success states
Gold#FFD700rgb(255, 215, 0)Highlights, badges
Coral#FF7F50rgb(255, 127, 80)CTAs, buttons
Slate Gray#708090rgb(112, 128, 144)Secondary text
Tomato#FF6347rgb(255, 99, 71)Warnings, tags
Teal#008080rgb(0, 128, 128)Brand accents

Common mistakes when converting color codes

Forgetting the hash symbol

A HEX code always starts with #. Without it, CSS will not recognize the color. Write #FF5733, not FF5733.

Mixing up channel order

RGB is always red, green, blue — not green, red, blue or any other order. Getting the order wrong produces an entirely different color.

Using decimal values above 255

An RGB channel cannot exceed 255. If your conversion produces a value above 255, double-check your math. Values like rgb(300, 0, 0) are invalid and will be ignored by browsers.

Confusing HEX case

HEX codes are case-insensitive. #ff5733 and #FF5733 produce the same color. However, uppercase is conventional.

Where to use each format

Use CaseRecommended FormatWhy
CSS stylesheetsHEXShorter, cleaner syntax
JavaScript color manipulationRGBEasier to parse and modify numerically
Design tools (Figma, Photoshop)RGBIndividual channel sliders
Tailwind CSSHEXMost Tailwind color utilities use HEX
SVG graphicsHEX or RGBBoth work; HEX is more compact
React inline stylesRGBrgb() works without quotes

Tips for working with color codes

  • Bookmark a converter so you never have to calculate manually during development
  • Use uppercase HEX (#FF5733) for consistency across your codebase
  • Store colors as HEX in CSS variables and convert to RGB only when you need transparency
  • Test contrast ratios after picking colors — use a contrast checker to verify accessibility
  • Keep a palette document with all your brand colors in both HEX and RGB formats

How to use the online converter

  1. Enter a HEX code (with or without the # prefix)
  2. The RGB equivalent appears instantly — no button click required
  3. To convert RGB to HEX, enter the red, green, and blue values (each 0-255)
  4. Copy the result with one click

Both directions work in real time with no page reloads.

What about other color formats?

HEX and RGB are the two most common formats, but they are not the only ones. HSL (Hue, Saturation, Lightness) and CMYK (Cyan, Magenta, Yellow, Black) serve different purposes. HSL is useful for generating color variations programmatically, while CMYK is used in print design. For web and screen work, HEX and RGB remain the standard.

Final thoughts

Converting between HEX and RGB is a foundational skill for any developer or designer. Once you understand the base-16 to base-10 conversion, you can translate any color code manually. For faster workflow, use the online converter to get instant, error-free results every time.

hex to rgb
rgb to hex
color code converter
hex color format
rgb color values
web design colors
Share this article

Related tools

Frequently Asked Questions

J

Jalal Khan

Web developer and Registered Nurse-in-training who verifies every health-related calculator formula on UtilityHub.

About the author

Related articles

View all
CSS Gradient Generator: Create Gradients for Your Website
Color ToolsAug 20, 20266 min read

CSS Gradient Generator: Create Gradients for Your Website

Create CSS gradients with a generator: understand linear and radial gradients, color stops, and generate ready-to-use CSS code instantly.

Read article
How to Convert JPG to PDF on Any Device
Featured
PDF ToolsAug 24, 20265 min read

How to Convert JPG to PDF on Any Device

Turn JPG photos, scans, and screenshots into a single PDF in your browser. Free method that works on phone and desktop, with ordering and privacy tips.

Read article
How to Merge PDF Files Online for Free
Featured
PDF ToolsAug 24, 20265 min read

How to Merge PDF Files Online for Free

Learn how to merge PDF files into one document in the right order, avoid common mistakes, and keep private files secure - right in your browser, free.

Read article