Skip to content

RGB to HEX Converter: Instant Color Code Lookup

Convert RGB color values to HEX color codes instantly.

Last updated

Reviewed by Assoc. Prof. Rahela Kulčar, PhD, Associate Professor, University of Zagreb.
Three overlapping red, green, and blue circles converting to a hexadecimal colour code through a directional arrow.RGB#2563EBHEX
RGB and HEX encode the same colour information in different notation.
HEX#2563EB

Contrast on white & black

WCAG 2.1 contrast ratio of #2563EB against a white and a black surface.

5.17:1On white
AA PASSAA large PASSAAA FAIL
4.06:1On black
AA FAILAA large PASSAAA FAIL

AA needs 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold); AAA needs 7:1. Use this to choose white or black text over the color.

 

About this conversion

RGB and HEX represent the exact same color information in different notation. RGB uses three decimal numbers (0–255 each), while HEX packs the same values into a six-character hexadecimal string preceded by a hash. The conversion is purely mathematical — no color information is gained or lost.

The reason HEX dominates web development is historical: early HTML supported HEX color attributes before CSS existed, and the format stuck. Today, CSS accepts both rgb(37, 99, 235) and #2563EB, but HEX remains the default in most style guides, design tokens, and brand documentation because it is more compact and easier to copy as a single string.

One practical difference matters for developers: HEX does not natively support alpha transparency. If you need a semi-transparent color, you either use the 8-digit HEX format (#2563EB80 for 50% opacity) or switch to rgba(). The 8-digit format works in all modern browsers but breaks in IE11 and some older email clients. For email HTML, stick to 6-digit HEX or named colors.

This tool outputs uppercase 6-digit HEX codes, which is the most widely compatible format. If you also need the CMYK breakdown for print work, the RGB to CMYK converter takes the same input values.

Chart showing 12 common RGB values with their HEX equivalents, grouped by primary, secondary, and neutral colours.Common RGB → HEX ReferencePrimaryRedrgb(255, 0, 0)#FF0000Greenrgb(0, 255, 0)#00FF00Bluergb(0, 0, 255)#0000FFYellowrgb(255, 255, 0)#FFFF00SecondaryCyanrgb(0, 255, 255)#00FFFFMagentargb(255, 0, 255)#FF00FFOrangergb(255, 128, 0)#FF8000Purplergb(128, 0, 128)#800080NeutralWhitergb(255, 255, 255)#FFFFFFSilverrgb(192, 192, 192)#C0C0C0Grayrgb(128, 128, 128)#808080Blackrgb(0, 0, 0)#000000
RGB and HEX represent the same colour information. HEX is more compact; RGB is easier to read at a glance.

Worked examples

Real conversions this tool produces — enter the inputs to reproduce each result.

Encoding a brand blue for CSS

Input

Red (R)
37
Green (G)
99
Blue (B)
235

Result

HEX
#2563EB

Each channel becomes a two-digit hex pair: 37 → 25, 99 → 63, 235 → EB. Read a hex backwards and you can estimate the RGB without a tool — EB is near 255, so this blue is almost maxed.

A pure web orange

Input

Red (R)
255
Green (G)
102
Blue (B)
0

Result

HEX
#FF6600

255 → FF and 0 → 00, the two extremes of a hex pair. Any channel at FF is fully on; any at 00 is fully off.

An emerald accent (the site's success colour)

Input

Red (R)
16
Green (G)
185
Blue (B)
129

Result

HEX
#10B981

Green dominates at 185 (B9) with a meaningful blue (81) — that blue is what makes it an emerald rather than a grassy green.

Related content

Was this page helpful?

Color conversions are mathematical approximations. For critical color work, verify against physical swatch books and printed proofs. See our methodology and full disclaimer.

Frequently Asked Questions

What is a HEX color code?

A HEX color code is a six-character string (like #FF5733) that represents a color using hexadecimal notation. Each pair of characters encodes the red, green, or blue channel as a value from 00 to FF (0–255 in decimal). HEX codes are the standard way to specify colors in CSS, HTML, SVG, and most design tools.

Is the RGB to HEX conversion lossless?

Yes. Both formats describe the same sRGB color space using different notation. Converting back and forth always produces identical values. The only caveat is rounding: if you start with fractional RGB values (common in color pickers that use percentages), they are rounded to the nearest integer before HEX encoding.

Can I use shorthand HEX codes?

Yes. When each pair of hex digits is identical (e.g., #FF3366), you can shorten it to three characters (#F36). However, this tool always outputs the full six-digit format for maximum compatibility. Note that 8-digit HEX (#RRGGBBAA) for transparency is also valid in modern CSS but not supported in older email clients or IE11.

Should I use HEX or RGB in my CSS?

Both are equally valid in modern CSS. HEX is more compact and widely used in design systems and brand guidelines. RGB is easier to read when you need to understand channel values at a glance or calculate contrast ratios. For programmatic color manipulation (darkening, lightening, mixing), HSL is often more intuitive than either — see our RGB to HSL converter.

Does HEX work for print colors?

HEX and RGB describe screen colors (additive light). Printers use CMYK (subtractive ink). A HEX code defines how a color looks on a monitor, not on paper. To get print-accurate values, convert to CMYK using our RGB to CMYK converter, and be aware that some vivid screen colors cannot be reproduced in ink.

Cite or embed this tool

Cite this tool

PrinterTools. (2026). RGB to HEX Converter: Instant Color Code Lookup [online tool]. https://printertools.net/tools/rgb-to-hex

Embed this tool

Paste this on your site to link readers to the free tool. It renders as:

<a href="https://printertools.net/tools/rgb-to-hex" target="_blank" rel="noopener" style="display:inline-flex;align-items:center;gap:8px;padding:10px 14px;border:1px solid #e2e8f0;border-radius:8px;background:#ffffff;font-family:system-ui,-apple-system,sans-serif;font-size:14px;line-height:1.3;color:#2563eb;text-decoration:none;">RGB to HEX Converter: Instant Color Code Lookup — free tool by PrinterTools</a>

More Print calculators

Browse all print calculators — Color converters for RGB, HEX, CMYK, HSL, HSV, Pantone, RAL, and NCS — plus DPI, paper size, contrast, and ink estimators.