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

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
Enter a HEX color
Use three, four, six, or eight hexadecimal digits. The converter expands shorthand and includes alpha when supplied.
- 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
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.