Developer

RGB to HEX Converter

Turn red, green, and blue values into a HEX color code, including 3-digit shorthand.

Developer

Why Use the RGB to HEX Converter?

Set red, green and blue values from 0 to 255 with the number fields or sliders, and this rgb to hex converter writes the matching HEX code as you go. When your color can be abbreviated, it also shows the 3-digit shorthand, so you know at once whether #66CCFF can become #6CF. A step-by-step breakdown divides each channel by 16 and shows the remainder, making the result easy to verify. It helps front-end developers, students and anyone copying colors out of software that only shows RGB.

How to Use the RGB to HEX Converter

  1. Type values into the Red, Green and Blue fields, or drag their sliders, using whole numbers from 0 to 255.
  2. Watch the HEX code update with every change; when each pair has matching digits, the 3-digit shorthand appears as well.
  3. Read the step-by-step breakdown to see each channel divided by 16, for example 99 ÷ 16 = 6 remainder 3, which becomes 63.
  4. Press Copy on the HEX code or the shorthand and paste it into your CSS, design tool or brand document.

Best For

  • Converting RGB values read from a screenshot tool or image editor into HEX for a stylesheet.
  • Translating RGB brand specifications from a style guide into the HEX codes that CMS themes and design tools ask for.
  • Nudging a single channel with its slider, such as adding a little red to warm a color, while watching the HEX code change.
  • Checking whether a color can be written as 3-digit shorthand to keep CSS compact.

Pro Tip

Some environments, including SwiftUI, the Figma plugin API and GLSL shaders, express channels as decimals from 0 to 1 instead of 0 to 255. Multiply those by 255 and round before entering them here, so 0.5 becomes 128 (hex 80) and 0.2 becomes 51 (hex 33). Using one consistent rounding rule stops the same color drifting by a single step between platforms.

FAQ

RGB to HEX Converter FAQ

How do I convert RGB to HEX?

Divide each channel by 16. The whole-number result is the first hex digit and the remainder is the second, with 10 to 15 written as A to F. For rgb(255, 99, 71): 255 ÷ 16 = 15 remainder 15 gives FF, 99 ÷ 16 = 6 remainder 3 gives 63, and 71 ÷ 16 = 4 remainder 7 gives 47, so the code is #FF6347.

When can a HEX code be shortened to 3 digits?

Only when each of the three pairs is a repeated digit, such as #66CCFF, which shortens to #6CF. In RGB terms, every channel must be a multiple of 17 (0, 17, 34 and so on up to 255). If any channel breaks that pattern, the full 6-digit code is required.

Why do RGB values go from 0 to 255?

Standard web colors use 8 bits per channel, and 8 bits can store 256 values, numbered 0 to 255. With three channels that gives 256 × 256 × 256 = 16,777,216 possible colors. Two hexadecimal digits also cover exactly 256 values, which is why each channel maps neatly onto one HEX pair.

Are HEX color codes case sensitive?

No. #FF6347, #ff6347 and #Ff6347 are the same color to browsers and design tools. Teams usually pick one style, often lowercase in code and uppercase in design documents, purely for consistency and easier searching.

Learn more

Guides for the RGB to HEX Converter

How to Convert HEX to RGB (and RGB to HEX) Step by Step

Learn how to convert HEX to RGB and back by hand with worked examples, the RGB to HEX formula, shorthand and 8-digit codes, plus copy-ready JavaScript.

Read Guide
Copied