Hex Color Converter
Convert hex color codes to and from RGB, RGBA, CMYK, and a named reference swatch with a live color preview. Each conversion runs bidirectionally, and a nearest-swatch lookup matches input colors against a generated 1,354-entry reference palette using Euclidean distance in RGB space, reporting how far off the match is.
This tool sends nothing over the network. Everything you enter is processed on your device and never reaches our servers.
Documentation
A hex color converter takes a color entered in Hex, RGB, RGBA, CMYK, or as a named reference swatch, and returns the equivalent value in all five formats at once, with a preview swatch showing the result.
Hex accepts a six-digit code with or without the leading hash, in either uppercase or lowercase; three-digit shorthand codes such as #F0C expand automatically to their six-digit equivalent. RGB takes integer values from 0 to 255 for each of the red, green, and blue channels; fractional input such as 127/2 or a mixed number such as 63 1/2 is parsed and clamped to the valid range.
RGBA adds an alpha channel from 0 to 1, where 0 is fully transparent and 1 is fully opaque; decimal values such as 0.5 set partial transparency. CMYK takes percentage values from 0 to 100 for cyan, magenta, yellow, and key (black), converted with the standard formula R = 255 * (1 - C/100) * (1 - K/100), with the equivalent calculation for the green and blue channels: G = 255 * (1 - M/100) * (1 - K/100), and B = 255 * (1 - Y/100) * (1 - K/100).
A reference swatch is named by hue family, chroma tier, and tone, so Azure 500 is the mid tone of the azure family at standard chroma, and Cool Grey 800 is a dark neutral. Selecting a swatch converts it to every other format the same way a typed value would.
Converting between hex, RGB, and RGBA is exact in either direction, since all three notations describe the same additive red, green, and blue channels, only formatted differently. Converting to or from CMYK is an approximation: the formula above assumes ideal ink with no paper stock, press profile, or color management applied, so a computed CMYK breakdown is a starting point for prepress rather than a guaranteed match to a printed result.
Settings controls whether hex output is uppercase or lowercase and how many decimal places CMYK percentages show. Inputs and settings persist between sessions in the browser, so returning to the page restores the most recent conversion, and clearing the inputs restores the default color and every setting to its starting value.
This converter does not look up proprietary spot color systems. Pantone, RAL, NCS, HKS, TOYO, and DIC all license their color libraries commercially and their screen values are not free to redistribute, so there is no lookup by PMS number or equivalent code here and none is planned.
Converting one is still straightforward. Given a licensed swatch book or a subscription that provides the sRGB or hex value for a proprietary color, entering that value in Hex or RGB mode returns every other format exact, because the maths runs on the value supplied rather than on a stored table. Only the lookup step is missing, and that step is the part nobody may redistribute.
The reference swatch list is generated, not sampled from any commercial system. Its 1,354 entries are spaced evenly in the OKLCH perceptual color space across 24 hue families, five chroma tiers, and eleven tones, plus three neutral ramps. It is built for browsing and for constructing tints and shades, and it makes no attempt to approximate a licensed library. Whenever the tool names a closest swatch it prints the distance beside it, so the label is never mistaken for a match.
Color format conversion is a routine task across multiple disciplines where different tools and output media require specific color notations. Converting between hex, RGB, RGBA, CMYK, and a named swatch bridges the gap between screen-based and print-based workflows.
- Web Development: Extract an RGB or RGBA value from a design mockup and convert it to a hex code for CSS stylesheets. Enter rgb(52, 152, 219) channel values to get #3498DB for use in background-color, border, or gradient declarations.
- Print Design: Convert a hex brand color to CMYK percentages before sending artwork to a commercial printer. A web color of #E74C3C translates to approximate CMYK values that a prepress technician can verify against the print profile.
- Brand Guidelines: Document a brand palette in every required format. Enter each brand color once and record the hex, RGB, and CMYK values in a single conversion step, ensuring consistency across digital and physical media.
- UI and UX Design: Adjust transparency for overlay elements by converting an RGB color to RGBA with a specific alpha value. An alpha of 0.85 gives a semi-transparent navigation bar background, ready to copy into a design tool or stylesheet.
- Illustration and Digital Art: Recreate a physical illustration in a digital canvas application by entering the spot color value from a swatch book and reading off the hex or RGB output for the color picker.
- Email Marketing: Convert brand colors to hex codes that render consistently across email clients. Many email rendering engines support only hex notation, so converting from RGB or CMYK to hex ensures the intended color appears in the inbox.
- Accessibility Auditing: Convert colors between formats to calculate contrast ratios. Foreground and background colors entered in any supported format can be read off in hex or RGB for a contrast checker to verify WCAG compliance.
Inputs, outputs, and what the Hex Color Converter computes
What the Hex Color Converter asks for and what it returns, as a plain list. Defaults, units, and ranges are the ones the form loads with.
Inputs
- Hex / RGB / RGBA / CMYK / Reference swatch · default: Hex
- Hex Code (text input) · default: #3498DB
- Red (R) (text input) · default: 52
- Green (G) (text input) · default: 152
- Blue (B) (text input) · default: 219
- Alpha (A) (text input) · default: 1
- Cyan (C) % (text input) · default: 76
- Magenta (M) % (text input) · default: 31
- Yellow (Y) % (text input) · default: 0
- Key/Black (K) % (text input) · default: 14
- Swatch Name (text input)
- Uppercase hex output · default: on
- CMYK decimal places · default: 2
Controls
Convert · Reset