RGB to CMYK converter: the formula step by step, with examples

By TechCompare · Updated · How we check

rgb(239, 68, 68) comes out as cmyk(0%, 72%, 72%, 6%). Black is 1 minus the largest channel, and each other ink is the gap between its channel and that largest value, divided by it.

  • CMYKcmyk(0%, 72%, 72%, 6%)
  • HEX#EF4444
  • HSLhsl(0, 84%, 60%)

The converter above turns red, green and blue into cyan, magenta, yellow and black percents. Type three whole numbers from 0 to 255, either plain or in the rgb(...) form. This page shows the math behind those percents, so you can check a number by hand or explain one to someone else.

Conversion
RGB to CMYK
Example: rgb(239, 68, 68)
Category
Print Formats
Color knowledge base

How this is calculated

Divide each channel by 255 to scale it from 0 to 1. Find the largest of the three scaled values. Black (K) is 1 minus that largest value. Cyan, magenta and yellow each come from 1 minus their own channel, minus K, divided by 1 minus K. Then round each result to a whole percent. Because K is 1 minus the largest value, the same numbers reduce to something simpler: the largest value minus a channel, divided by the largest value. The two forms are the same math.

Take the example color, #EF4444, which is rgb(239, 68, 68). Red is the largest channel at 239, so black is 1 minus (239 divided by 255), which rounds to 6%. Cyan is the ink for red, so it's 0%. Magenta is (239 minus 68) divided by 239, which rounds to 72%, and yellow is (239 minus 68) divided by 239, which rounds to 72%.

Pure black needs its own rule. Its largest channel is 0, so K is 100%, and the divisor 1 minus K would be zero. The converter sets black to 100% with the other inks at zero, which gives cmyk(0%, 0%, 0%, 100%). Pure red is cmyk(0%, 100%, 100%, 0%), pure green is cmyk(100%, 0%, 100%, 0%) and white is cmyk(0%, 0%, 0%, 0%). This is the plain math behind the converter, not a press conversion. RGB and CMYK are device-dependent, so these numbers are a starting point, and the Hex to CMYK page covers the print handoff.

Verdict

Use the formula to check a converter number or to explain one to someone else. For a print file, treat this formula as the first step and convert with the printer's CMYK profile. The same three channels can give other percents in a different profile, so keep the RGB values as your source.

More Color scenarios

Hex to RGB
A hex color code is three RGB numbers written in base 16.
View details
RGB vs CMYK
Screens add light and print adds ink. See one color in both, and why a plain CMYK formula can't promise a print match.
View details
HSL color model
Hue, saturation and lightness, with three live sliders and a table of common colors in hex, RGB and HSL.
View details

Frequently asked questions

What is K in CMYK?
K is the black ink, which Wikipedia says printers call the key plate. The formula only needs it as an amount: 1 minus the largest channel. A color with a channel near full gets little K, and a dark color gets more.
Why are the CMYK numbers for a gray only K?
A gray has the same value in all three channels, so cyan, magenta and yellow each work out to zero, and only black is left. Mid gray, #808080, is cmyk(0%, 0%, 0%, 50%).
Can the formula give a number above 100?
No. Each ink is the largest channel minus the channel that ink matches, divided by the largest channel. No channel is above the largest, so each result stays from 0 to 1. Rounding can't push it past 100 either. Pure red reaches the top of the range with cmyk(0%, 100%, 100%, 0%).
What does the converter do with 0, 0, 0?
It reads them as black, which the converter writes as cmyk(0%, 0%, 0%, 100%). Decimals, percent signs and numbers above 255 don't work for RGB, and they show an error under the field.