Rgb Calculator
Type red, green, and blue values to get the HEX code and rgb() string.
Colors on screens are built from three numbers: how much red, how much green, and how much blue. Designers, developers, and bloggers constantly need to turn those three numbers into the HEX code that websites and apps actually use. This RGB calculator does that conversion instantly, showing you the HEX code, the CSS rgb() string, and a live preview swatch of the exact color.
What This Calculator Does
You type three whole numbers between 0 and 255, one for red, one for green, and one for blue. The calculator converts each number into its two-digit hexadecimal form and joins them into a six-digit HEX code with a hash sign in front, like #FF5733. It also builds the matching CSS rgb() string, such as rgb(255, 87, 51), which you can paste straight into a stylesheet. A preview swatch shows the color itself so you can confirm it looks right before you use it. Every value is validated, so a typo like 256 or a blank field gives you a clear message instead of a broken result.
How to Use This Calculator
Enter the red value first, then green, then blue, using whole numbers from 0 to 255. Zero means none of that color and 255 means the maximum. If you are copying values from a design tool, type them exactly as shown, including zeros. Press Calculate to see your HEX code, the rgb() string, and the preview swatch. The Reset button clears all three fields so you can convert another color. There are no extra settings and nothing to sign up for: three numbers in, two color formats out.
Understanding RGB and HEX
RGB is an additive color model used by screens. Each pixel mixes red, green, and blue light, and each channel gets 256 possible levels, from 0 to 255. Black is 0, 0, 0 because no light is emitted, and white is 255, 255, 255 because all three channels are at full power. Pure red is 255, 0, 0, pure green is 0, 255, 0, and pure blue is 0, 0, 255. HEX is simply another way to write the same three numbers, using base sixteen instead of base ten. In hexadecimal, 255 becomes FF, 0 becomes 00, and 87 becomes 57. So the RGB color 255, 87, 51 becomes the HEX code #FF5733. Both formats describe the identical color; HEX is just shorter and more common in web design.
Worked Examples With Full Arithmetic
Example one: convert the RGB values 255, 87, 51. Convert each channel to two-digit hexadecimal. For red, 255 divided by 16 is 15 with a remainder of 15, and in hexadecimal 15 is F, so 255 becomes FF. For green, 87 divided by 16 is 5 with a remainder of 7, and 5 and 7 stay as digits, so 87 becomes 57. For blue, 51 divided by 16 is 3 with a remainder of 3, so 51 becomes 33. Join them with a hash sign and the result is #FF5733, a warm orange-red. The CSS string is rgb(255, 87, 51).
Example two: convert 0, 128, 0, a medium green. Red is 0, which becomes 00. For green, 128 divided by 16 is 8 with a remainder of 0, so 128 becomes 80. Blue is 0, which becomes 00. The HEX code is #008000 and the CSS string is rgb(0, 128, 0). Notice how a single-digit hex value like 0 always gets a leading zero so every channel is exactly two digits.
Example three: convert 75, 0, 130, a deep purple. For red, 75 divided by 16 is 4 with a remainder of 11, and in hexadecimal 11 is B, so 75 becomes 4B. Green is 0, which becomes 00. For blue, 130 divided by 16 is 8 with a remainder of 2, so 130 becomes 82. The HEX code is #4B0082 and the CSS string is rgb(75, 0, 130). This is the well-known web color indigo.
Where You Will Use HEX Codes
HEX codes appear almost everywhere in digital design. Website stylesheets use them for text colors, backgrounds, buttons, and borders. Bloggers paste them into theme customizers to match brand colors. App designers share them with developers so everyone builds the same shade. Social media managers use them in tools like Canva to keep post graphics consistent. Even email templates and presentation slides accept HEX codes. Whenever a tool asks for a color in the #RRGGBB format, this calculator gives you a value you can copy with confidence.
Common Mistakes to Avoid
The most common mistake is entering a value above 255, often by typing something like 256 or 1000. Each channel only has 256 levels, so anything higher is invalid. Another frequent error is mixing up the channel order and typing the green value into the red field, which produces a completely different color. Some people also enter decimals like 128.5, but RGB channels must be whole numbers. A subtler mistake is copying a HEX code and typing its digits as if they were RGB numbers: #FF is not the RGB number 255 in the way people expect when they type the letters. Finally, remember that the same HEX code can look slightly different on different screens, so always check the preview on the device your audience will use.
Frequently Asked Questions
1. What does RGB stand for?
RGB stands for Red, Green, and Blue, the three colors of light that screens mix to create every color you see. Each channel gets a value from 0 to 255, and different combinations produce millions of possible colors.
2. What is a HEX color code?
A HEX color code is a six-digit code that writes RGB values in hexadecimal, like #FF5733. The first two digits are red, the middle two are green, and the last two are blue. It describes the exact same color as the RGB numbers, just in a shorter format.
3. How do I convert RGB to HEX by hand?
Convert each channel separately: divide the number by 16, write the quotient as a hex digit, then write the remainder as a hex digit. For example, 87 divided by 16 is 5 remainder 7, so it becomes 57. Do this for all three channels and join them with a hash sign.
4. Why must RGB values be between 0 and 255?
Because each channel is stored as one byte of data, and one byte can hold exactly 256 values. Zero means the channel is off and 255 means it is fully on. Values outside this range cannot be displayed by standard screens.
5. Can I use decimals in RGB values?
No, RGB channels must be whole numbers. A value like 128.5 is not valid. Round to the nearest whole number before entering it, since screens cannot display a fraction of a color level.
6. What is the HEX code for black and white?
Black is rgb(0, 0, 0), which converts to #000000, and white is rgb(255, 255, 255), which converts to #FFFFFF. Try both in the calculator to see the swatches change.
7. What is the rgb() string used for?
The rgb() string is a CSS function that sets colors in stylesheets, like color: rgb(255, 87, 51). It means the same thing as the HEX code, so you can use whichever format your tool accepts.
8. Are HEX codes case sensitive?
No. The code #ff5733 and #FF5733 describe the same color. This calculator shows uppercase letters, which is the most common convention, but lowercase works everywhere too.
9. Why does the same HEX code look different on my phone and laptop?
Every screen has its own brightness, contrast, and color calibration, so the same code can look slightly warmer or cooler from one device to another. For critical brand colors, check the preview on the screens your audience actually uses.
10. What is the difference between RGB and CMYK?
RGB is an additive model for screens that mixes light, while CMYK is a subtractive model for printing that mixes ink. A bright RGB color often looks duller in print, so designers convert between the two when a design moves from screen to paper.
11. How many colors can RGB represent?
With 256 levels per channel and three channels, RGB can represent 256 times 256 times 256, which equals 16,777,216 colors. That is far more than the human eye can distinguish, which is why it works so well for photos and video.
12. What does the preview swatch show?
The swatch fills with the exact color your three numbers describe. It is a quick visual check that catches mistakes like swapped channels, which are easy to miss when you only look at numbers.
13. Can I enter values with leading zeros?
Yes. Entering 007 works the same as entering 7, because the calculator reads the numeric value. Each channel is still validated to be between 0 and 255.
14. What if I only know the HEX code?
Split the six digits into three pairs and convert each pair from hexadecimal to decimal. For example, in #FF5733 the pair FF is 255, 57 is 87, and 33 is 51, giving you rgb(255, 87, 51).
15. Is this calculator free to use?
Yes, it is completely free and runs entirely in your browser. Convert as many colors as you like, with no accounts, no limits, and no data leaving your device.
Final Thoughts
Converting RGB to HEX is one of those small tasks that comes up constantly in design work, and doing it by hand invites mistakes. This RGB calculator turns three numbers into a HEX code, a CSS rgb() string, and a live preview in one click. Bookmark it, keep it open next to your design tool, and never hand-convert a color again.