Skip to main content

RGB to HEX & HEX to RGB Converter

Convert RGB to HEX or HEX to RGB with shorthand, percentage and alpha support, modern CSS syntax, live validation and copy-ready values.

Convert a color

RGB to HEX

RGB
rgb(20, 120, 201)
Modern CSS RGB
rgb(20 120 201)
Percentage RGB
rgb(7.8% 47.1% 78.8%)
HSL
hsl(207 82% 43%)
CMYK
cmyk(90% 40% 0% 21%)
OKLCH
oklch(56.24% 0.1507 249.81)
Use this color in a CSS gradientOpen the gradient maker to combine this value with editable stops, transparency, and production-ready CSS.
Bidirectional RGB and HEX converter with synchronized color preview and modern CSS formats.
Bidirectional RGB and HEX converter with synchronized color preview and modern CSS formats.

Quick answer

HEX stores red, green, blue, and optional alpha as hexadecimal pairs. This converter decodes or encodes those channels instantly, then derives modern CSS RGB, HSL, CMYK, and OKLCH representations from the same underlying sRGB color.

Quick guide

How to convert HEX and RGB colors

Convert in either direction while keeping a synchronized color preview. The result is ready for CSS, design tokens, or a developer handoff.

  1. 1

    Enter a HEX color

    Use three, four, six, or eight hexadecimal digits. The converter expands shorthand and includes alpha when supplied.

  2. 2

    Or enter RGB channels

    Set red, green, and blue from 0 to 255. Use an alpha value from 0 to 1 when the color needs transparency.

  3. 3

    Copy the result

    Check the live swatch, then copy classic or modern RGB, percentage RGB, HSL, CMYK, or OKLCH.

Practical uses

CSS implementation

Translate design HEX tokens into RGB or RGBA values for styles, effects, and programmatic color work.

Design handoff

Confirm that designers and developers are referring to the same underlying color in different formats.

Legacy color cleanup

Normalize shorthand HEX and mixed RGB values before moving them into a reusable token system.

Method and accuracy

How this tool works

For HEX to RGB, each hexadecimal pair is parsed into an integer from 0 to 255; shorthand digits are doubled and an optional fourth pair becomes alpha. HSL is derived from normalized channel extrema, CMYK is a device-independent approximation, and OKLCH is calculated by linearizing sRGB before converting through OKLab. Fixed reference vectors in the test suite verify black, white, and primary colors.

Frequently asked questions

How do I convert HEX to RGB?

Enter a valid HEX value. Each two-digit pair becomes a red, green, or blue channel from 0 to 255, and the RGB result updates immediately.

Are shorthand and alpha HEX values supported?

Yes. The converter accepts 3-, 4-, 6-, and 8-digit HEX, including shorthand and alpha-channel formats.

What is the valid RGB range?

Red, green, and blue must each be between 0 and 255. Alpha is optional and must be between 0 and 1.