HEX to RGB Color Converter - Free Online Color Tool

Convert any hex color code to RGB, HSL, and CMYK instantly. Free hex to RGB color converter — runs in your browser, no sign-up needed.

HEX#10b981
RGBrgb(16, 185, 129)
HSLhsl(160, 84%, 39%)
CMYKcmyk(91%, 0%, 30%, 27%)

Tints & shadesclick to use

Contrast (WCAG)

Aa
White text · 2.54:1
AA AA large AAA
Aa
Black text · 8.28:1
AA AA large AAA

Paste a hex code, get the RGB value instantly

Drop any hex color code into the field above and the tool spits out the matching RGB, HSL, and CMYK values right away — no sign-up, no page reload. It also generates tints and shades and checks whether two colors meet WCAG contrast requirements for accessibility (AA and AAA levels).

How to use the hex to RGB color converter

  1. Type or paste your hex code into the input — with or without the # symbol (e.g. #3B82F6 or 3B82F6).
  2. The RGB, HSL, and CMYK values appear instantly below the input.
  3. Click any value to copy it to your clipboard.
  4. Optionally, enter a second color to run a WCAG contrast check — useful for confirming text is readable on a background.
  5. Scroll down the result panel to see the full tint and shade scale for your color.

Worked example — converting #3B82F6 to RGB

Say you grabbed Tailwind CSS's blue-500 value: #3B82F6. Here's what the converter produces:

Format Value What it means
HEX (#RRGGBB) #3B82F6 Six hex digits — two each for red, green, and blue (0–FF)
RGB rgb(59, 130, 246) Three numbers from 0 to 255, one per color channel
HSL hsl(217, 91%, 60%) Hue (0–360°), Saturation, Lightness — easier to tweak visually
CMYK cmyk(76%, 47%, 0%, 4%) Cyan, Magenta, Yellow, Key (Black) — used in print design

The contrast ratio against white (#FFFFFF) is 3.14:1, which passes WCAG AA for large text but not for normal-sized body copy — handy to know before you commit to that text color.

How to convert hex to RGB in code

If you need this conversion inside your own project, here are clean one-liners for the two most common languages.

JavaScript

// Returns { r, g, b } from a hex string like '#3B82F6'
function hexToRgb(hex) {
  const clean = hex.replace('#', '');
  return {
    r: parseInt(clean.substring(0, 2), 16),
    g: parseInt(clean.substring(2, 4), 16),
    b: parseInt(clean.substring(4, 6), 16)
  };
}

hexToRgb('#3B82F6'); // { r: 59, g: 130, b: 246 }

Python

# Returns (r, g, b) tuple from a hex string like '#3B82F6'
def hex_to_rgb(hex_color):
    hex_color = hex_color.lstrip('#')
    return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))

hex_to_rgb('#3B82F6')  # (59, 130, 246)

Both snippets parse each pair of hex digits as a base-16 number. For a deeper look at base conversion, see our Hex to Decimal Converter — Free Online Base Converter.

How it works

A hex color like #3B82F6 is just three base-16 numbers written back to back. The converter splits the string into three two-character chunks (3B, 82, F6), then converts each from hexadecimal (base 16) to a decimal (base 10) number between 0 and 255 — giving you the red, green, and blue channels of the RGB model.

The HSL conversion then maps those RGB values to a hue angle, a saturation percentage, and a lightness percentage using standard formulas defined in the W3C CSS Color Level 4 specification. CMYK is derived from RGB by a straightforward normalization — useful for screen-to-print handoff.

When to use (and when to skip) a hex-to-RGB converter

Good times to reach for this tool

  • Copying a color out of a design file (Figma, Sketch) and needing rgb() syntax for CSS.
  • Working in a framework like React or Vue where you pass color channels as separate props.
  • Checking WCAG contrast before finalizing text and background color pairings.
  • Translating a hex code to CMYK for a print vendor or PDF export.
  • Generating a full tint-to-shade palette from a single brand color.

When you may not need it

  • Modern CSS accepts hex values directly (color: #3B82F6), so no conversion is needed for standard styling.
  • If you're already working in a color library like chroma.js or Python's colorsys module, those handle conversions programmatically in one call.
  • Shorthand hex codes like #F00 (three-digit) expand to #FF0000 — make sure you're not passing a three-digit code to a parser that expects six digits, or use the tool to expand it first.

Your data never leaves your browser. All conversions run entirely on your device — nothing is sent to a server, so you can safely paste internal brand colors or client assets.

Pick your color above, grab the format you need, and move on — the converter handles the math so you don't have to.

Frequently asked questions

What's the difference between HEX and RGB?+
They represent the same color in different notations. HEX writes each channel (red, green, blue) as a two-digit base-16 number joined into a six-character string (e.g. #3B82F6). RGB writes the same channels as three decimal numbers from 0 to 255 (e.g. rgb(59, 130, 246)). Both describe identical colors — it's purely a formatting difference.
Can I convert RGB back to hex?+
Yes. The converter works in both directions. Type an rgb() value into the input and it returns the hex code, HSL, and CMYK equivalents instantly.
Is my color data uploaded or stored anywhere?+
No. Every conversion runs directly in your browser. Nothing is sent to any server, and nothing is logged or stored. You can use it safely with client or internal brand colors.
How do I convert a hex color to RGB in JavaScript?+
Parse each two-character hex pair as a base-16 integer: parseInt('3B', 16) gives 59. The worked example and code snippet on this page show a ready-to-copy function.
What does the WCAG contrast check tell me?+
It measures the luminance ratio between two colors. WCAG AA requires at least 4.5:1 for normal text and 3:1 for large text. AAA is stricter at 7:1. The tool flags pass or fail so you know whether your text color is readable on its background before you ship.
Does this tool handle 3-digit (shorthand) hex codes like #F00?+
Yes. Three-digit codes are automatically expanded to their six-digit equivalent before conversion, so #F00 is treated as #FF0000.
Is the tool free? Do I need an account?+
Completely free, no account needed, no usage limits. Open the page and start converting.
What are tints and shades, and why would I need them?+
A tint mixes your color with white (lighter versions); a shade mixes it with black (darker versions). They're used to build color scales — the kind you see in Tailwind CSS or Material Design palettes. The tool generates a full scale from your single input color.