Skip to content

RGB to HEX Converter

Convert any RGB or RGBA color to a HEX code instantly, with a color picker, alpha support, shades and bulk conversion. Free and no signup.

  • 100% free
  • No Signup
  • Instant results
#2662D9

Paste rgb(), rgba() or plain numbers like 38 98 217.

Adjust with sliders
%

Shades & tints

Your color mixed with black (left) and white (right). Click a swatch to copy its HEX.

Color harmonies

Complementary, analogous and triadic colors based on your color.

Bulk RGB to HEX converter

Paste one RGB color per line (up to 200). Results follow the case and hash settings above.

0 colors converted
    ADVERTISEMENT
    Demo Ad 728 x 90

    How to convert RGB to HEX

    1. 1

      Enter RGB

      Paste an RGB value, use the sliders or pick a color with the color picker.

    2. 2

      See the HEX

      The HEX code, HSL value and a live preview update instantly.

    3. 3

      Copy it

      Copy HEX, short HEX, HEX with alpha or RGB with one click.

    RGB TO HEX COLOR GUIDE

    RGB to HEX Converter – Convert RGB and RGBA Colors to HEX Color Codes Online Free

    Need a quick and reliable RGB to HEX converter that works right in your browser? This free RGB to HEX color converter turns any red, green and blue values into a clean HEX color code the moment you enter them, with no signup, no software to install and nothing uploaded to a server. Type rgb(38, 98, 217) and you instantly get #2662D9, or drag the red, green and blue sliders, or use the built-in color picker, and watch the HEX code, the HSL value and the live preview update in real time. The converter understands every common way to write RGB, including rgb() and rgba(), the modern space-separated syntax, percentage values and plain numbers, so you can convert RGBA to HEX with transparency and copy an eight-digit HEX code with one click. You also get the short three-digit HEX whenever it is exact, a WCAG contrast check for white and black text, a ready set of shades and tints, color harmonies and a bulk converter that processes up to 200 colors at once. Whether you are a web developer writing CSS, a designer moving colors between Photoshop, Figma and Canva, a student learning how digital color works or a business owner matching a brand color, this online RGB to HEX tool gives you correct color codes in seconds.

    RGB to HEX Color Code Converter

    Convert RGB to HEX color code in one step and get a six-digit HEX such as #2E73B8 that works in CSS, HTML, design apps, page builders and brand guides. Pick uppercase or lowercase letters and decide whether to keep the hash symbol, so the result can be pasted straight into your project.

    RGBA to HEX With Alpha Transparency

    Want to convert RGBA to HEX or change an RGB color with opacity into an eight-digit HEX code? Set the alpha slider or paste rgba(255, 87, 51, 0.5) and the converter returns #FF573380, so overlays, shadows, buttons and semi-transparent backgrounds keep exactly the opacity you chose.

    Bulk RGB to HEX Converter

    Convert a whole list of RGB colors to HEX at once. Paste one color per line in any supported format and every line is converted immediately with a swatch preview. Copy all the HEX codes together, which is ideal for design tokens, theme files, CSS variables and brand palettes.

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

    Converting a color from RGB to HEX by hand takes a few calculations and it is easy to make a small mistake. With this online converter the whole job takes seconds. Follow these simple steps to convert any RGB color to a HEX code.

    1. Enter your RGB color: Type or paste the value into the RGB box, for example rgb(46, 115, 184). You can also move the red, green and blue sliders, type numbers in the fields next to them or click Pick color to choose a shade visually.
    2. Add transparency if needed: Move the alpha slider, or include an alpha value such as rgba(46, 115, 184, 0.8), to get a HEX code with an alpha channel.
    3. Check the preview and contrast: The large swatch shows the exact color, and the contrast boxes tell you whether white or black text is easier to read on top of it.
    4. Choose how the HEX is written: Switch between uppercase and lowercase letters and turn the hash symbol on or off to match your code style.
    5. Copy the result: Press Copy next to the HEX, short HEX, HEX with alpha, RGB or HSL line and paste it into your stylesheet, design file or document.

    Because everything runs in your browser, the converter responds instantly and keeps working even on a slow connection. There is nothing to upload and there is no limit on the number of colors you can convert.

    How RGB to HEX Conversion Works: The Formula Explained

    RGB describes a color with three numbers, each from 0 to 255, that tell a screen how much red, green and blue light to mix. A HEX color code is exactly the same information written in hexadecimal, a base-16 number system that uses the digits 0 to 9 and the letters A to F. Because 255 is the largest value one color channel can have, and 255 in hexadecimal is FF, every channel fits into exactly two hexadecimal digits. That is why a HEX color always has six digits: two for red, two for green and two for blue. The conversion follows a simple pattern for each channel.

    1. Divide the number by 16: The whole-number result is the first hexadecimal digit.
    2. Take the remainder: The remainder after dividing by 16 is the second hexadecimal digit.
    3. Replace values from 10 to 15 with letters: 10 becomes A, 11 becomes B, 12 becomes C, 13 becomes D, 14 becomes E and 15 becomes F.
    4. Repeat for red, green and blue: Convert each channel into a two-digit pair.
    5. Join the pairs: Write a hash symbol followed by the red pair, the green pair and the blue pair.

    Here is a worked example with rgb(38, 98, 217). For red, 38 divided by 16 is 2 with a remainder of 6, so red is 26. For green, 98 divided by 16 is 6 with a remainder of 2, so green is 62. For blue, 217 divided by 16 is 13 with a remainder of 9. Since 13 is D, blue is D9. Joining the pairs gives the HEX code #2662D9. This converter performs exactly this calculation for every color, instantly and without mistakes.

    Common decimal to hexadecimal channel values
    Decimal (0–255) Hexadecimal What it means
    000None of that color
    1610Very low intensity
    6440About 25% intensity
    12880About 50% intensity
    192C0About 75% intensity
    255FFFull intensity

    Common RGB to HEX Color Examples

    The table below lists popular RGB colors with their HEX codes. Use it as a quick reference to check a conversion or as a starting point for your own palette. You can paste any of the RGB values into the converter above to see the live preview and the other formats.

    RGB to HEX conversion examples
    Color RGB value HEX code
    Redrgb(255, 0, 0)#FF0000
    Greenrgb(0, 255, 0)#00FF00
    Bluergb(0, 0, 255)#0000FF
    Yellowrgb(255, 255, 0)#FFFF00
    Cyanrgb(0, 255, 255)#00FFFF
    Magentargb(255, 0, 255)#FF00FF
    Orangergb(255, 165, 0)#FFA500
    Purplergb(128, 0, 128)#800080
    Pinkrgb(255, 192, 203)#FFC0CB
    Forest greenrgb(34, 139, 34)#228B22
    Coral redrgb(255, 87, 51)#FF5733
    Royal bluergb(38, 98, 217)#2662D9
    Grayrgb(128, 128, 128)#808080
    Whitergb(255, 255, 255)#FFFFFF
    Blackrgb(0, 0, 0)#000000

    Notice the pattern: pure red, green and blue each have one channel at FF and the other two at 00, and every shade of gray has the same value in all three channels, such as 80, 80, 80. These patterns make it easy to read many HEX codes at a glance once you know the system.

    RGB vs HEX vs HSL: What Is the Difference?

    RGB, HEX and HSL all describe the same colors on a screen, but each one is written differently and fits different jobs. Knowing how they compare explains why so many people need an RGB to HEX converter in their daily work.

    RGB vs HEX vs HSL color formats
    Feature RGB HEX HSL
    How it describes color Red, green, blue from 0 to 255 Red, green, blue in base 16 Hue, saturation, lightness
    Example rgb(38, 98, 217) #2662D9 hsl(220, 70%, 50%)
    Length and convenience Long, but easy to read Short and easy to copy Medium, easy to adjust
    Best for Code, canvas and image processing Design tools, CSS and sharing Building shades and themes
    Transparency rgba() or slash alpha Eight-digit HEX hsla() or slash alpha
    Short form No Yes, for example #FFF No

    In short, RGB is what screens actually use, HEX is the compact version that is easiest to share and store, and HSL is the most natural one to adjust by hand. Converting RGB to HEX gives you a short, universal code that almost every tool, website builder and design app accepts.

    Supported RGB Input Formats

    You do not need to retype your color in a special format. This RGB to HEX converter reads the formats you are most likely to copy from CSS files, design tools and documentation, and it clearly tells you when a value cannot be understood.

    RGB formats accepted by the converter
    Format Example Notes
    Classic rgb() rgb(38, 98, 217) Comma-separated, the most common form
    Modern rgb() rgb(38 98 217) Space-separated syntax from modern CSS
    rgba() with alpha rgba(38, 98, 217, 0.5) Alpha as a number from 0 to 1 or as a percentage
    Slash alpha rgb(38 98 217 / 50%) Modern CSS opacity syntax
    Percentages rgb(50%, 50%, 50%) Each channel as a percentage, converted to 0–255
    Plain numbers 38 98 217 Red, green and blue without any symbols

    RGBA to HEX: How Transparent HEX Codes and Opacity Work

    A standard HEX color has six digits. To store transparency, two extra digits are added for the alpha channel, giving an eight-digit HEX code. The alpha runs from 00, which is fully transparent, to FF, which is fully opaque. To convert RGBA to HEX, the alpha value from 0 to 1 is multiplied by 255, rounded and written in hexadecimal. For example, rgba(255, 87, 51, 0.5) becomes #FF573380, because 0.5 times 255 is 127.5, which rounds to 128, or 80 in hexadecimal.

    Opacity percentage to HEX alpha values
    Opacity Alpha (0–1) HEX alpha
    100%1FF
    90%0.9E6
    80%0.8CC
    70%0.7B3
    60%0.699
    50%0.580
    40%0.466
    30%0.34D
    20%0.233
    10%0.11A
    0%000

    Two details are worth knowing. First, on the web, in CSS and in Figma the alpha digits come last in the order RRGGBBAA, while Android resources expect the alpha first in the order AARRGGBB. If you copy an eight-digit HEX code into an Android project, move the last two digits to the front. Second, some charts show 7F for 50% opacity because they round down instead of up. This converter rounds to the nearest value, which gives 80, and the visual difference between the two is not noticeable.

    Short HEX Codes: When Can RGB Be Written With Three Digits?

    A three-digit HEX code such as #FFF or #09C is a shortcut for a six-digit one. Each digit is simply doubled, so #09C means #0099CC. This shortcut only works when each of the three channels has two identical digits, which means each channel value must be 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238 or 255. For example, rgb(255, 102, 0) becomes #F60 because FF, 66 and 00 each repeat. The converter shows the short HEX only when it is exact, and it leaves the field empty for colors that cannot be shortened, so you never copy a code that changes your color.

    Common Uses: Where Do You Need HEX Color Codes?

    HEX is the color format you will meet in the most places, which is why converting RGB to HEX is such a common task. After you convert, you can use the result almost anywhere. These are some of the most popular uses.

    • CSS and HTML: Set text, background, border and shadow colors with HEX values in stylesheets and inline styles.
    • Photoshop, Illustrator, Figma and Canva: Paste a HEX code into the color picker to match a color exactly across tools, or copy RGB values from the info panel and convert them here.
    • WordPress, Shopify and page builders: Most theme settings and customizers ask for a HEX color code.
    • Brand guidelines and style guides: HEX codes are the standard way to document and share brand colors with a team or a client.
    • Email and presentations: Email builders, slide decks and documents accept HEX values for exact color matching.
    • Charts and dashboards: Use HEX values for chart series, legends and reports so colors stay consistent across tools.
    • Game and app development: Many engines and design systems store colors as HEX strings in configuration and theme files.

    Shades, Tints and Harmonies From a Single RGB Color

    Once you have your HEX code, the same page helps you build a small palette. The Shades and tints section mixes your color with black to create darker shades and with white to create lighter tints, giving you a smooth scale of nine related colors that you can use for hover states, borders, backgrounds and disabled buttons. The Color harmonies section shifts the hue of your color to find its complement, its two analogous neighbors and its two triadic partners. Each swatch copies its HEX code with a single click, so you can move from one color to a complete, balanced palette in a few seconds.

    • Buttons and links: Use a darker shade for hover and active states and a lighter tint for disabled states.
    • Backgrounds and cards: A very light tint of your brand color makes a soft, matching background.
    • Accent colors: Use the complementary or triadic color for highlights and calls to action.
    • Charts: Analogous colors create a smooth, easy-to-read data series.

    Check Color Contrast for Readable, Accessible Text

    A color can look attractive and still be hard to read. To help, this converter calculates the WCAG contrast ratio between your color and white, and between your color and black, so you can see which text color works better on top of it. The Web Content Accessibility Guidelines recommend a ratio of at least 4.5 to 1 for normal text at level AA and 7 to 1 at level AAA, while large text needs at least 3 to 1 for level AA. Check contrast whenever you pick a button color, a banner background or a card color, and adjust the red, green and blue sliders until one of the two text colors passes.

    Tips for Accurate RGB to HEX Conversion

    A few small details can prevent confusing results. Keep these tips in mind whenever you convert colors from RGB to HEX.

    • Stay between 0 and 255: Values above 255 are not valid RGB, and this tool limits them to 255 so the HEX code stays correct.
    • Check the order of channels: RGB is always red, then green, then blue. Swapping them changes the color completely.
    • Pad single digits: A value like 5 becomes 05, not 5, so each channel always has two digits.
    • Watch the alpha order: Use RRGGBBAA for the web and AARRGGBB for Android.
    • Use short HEX only when exact: Never shorten a code by guessing, because the colors will not match.
    • Keep the original value: Store both the RGB and the HEX in your style guide so you can check them against each other later.
    • Test contrast early: Check text readability when you pick a color, not after the design is finished.

    Convert RGB to HEX on Any Device, No Software Needed

    This online RGB to HEX converter works in any modern web browser on Windows, Mac, Linux, Android and iPhone, so you can convert colors on your computer, tablet or phone. There is no app to install, no account to create and no plugin to add. The page does all the calculations locally, which makes it fast and private, and the large sliders, picker and copy buttons are easy to use on touch screens as well as with a mouse.

    Compared with doing the math yourself or writing a script, a visual converter is quicker and far less error-prone. You see the color, the HEX code, the HSL value and the contrast result together, which makes it easy to confirm that you have the right color before you copy it.

    RGB to HEX in JavaScript, Python and PHP

    Developers often need this conversion inside their own code. Each language can format a number as two hexadecimal characters.

    RGB to HEX code examples
    LanguageExample for rgb(38, 98, 217)Result
    JavaScript'#' + [38,98,217].map(n => n.toString(16).padStart(2,'0')).join('')#2662d9
    Python'#{:02x}{:02x}{:02x}'.format(38, 98, 217)#2662d9
    PHPsprintf('#%02x%02x%02x', 38, 98, 217)#2662d9

    In your own code, first limit each value to a whole number from 0 to 255. Decimal or out of range input can otherwise produce an invalid string.

    Percentage RGB to HEX

    CSS can express RGB channels as percentages. To convert by hand, multiply each percentage by 2.55 and round to a whole number, then convert it to base 16. For example, 100% is 255 or FF, 50% rounds to 128 or 80, and 0% is 00. If your source lists decimals from 0 to 1, as some game engines and design APIs do, multiply by 255 instead.

    Why Is My HEX Code Wrong? Common RGB to HEX Mistakes

    • Missing leading zero: The value 5 must be written as 05, not 5.
    • Swapped channels: The order in CSS HEX is red, green, blue. Some image libraries use blue, green, red.
    • Alpha in the wrong place: CSS places alpha last as RRGGBBAA, while Android color values place it first.
    • Sampled pixel differs: Compression and color profiles can change the pixel you pick from an image.
    • Short code guessed by eye: Shortening works only when both characters in every pair match.

    Where to Paste HEX Codes in Design and Office Apps

    Many design programs, website builders, presentation tools and email editors have a custom color box that accepts HEX. Some want the hash sign and others only the six characters, so use the hash option in this converter to match. Transparency support varies as well. If an app rejects an eight digit code, paste the six digit code and set opacity with the app control.

    Related RGB and HEX Tools

    Reverse the process with the HEX to RGB Converter, get hue based values from the RGB to HSL Converter, prepare print values with the RGB to CMYK Converter, or grab a code from an image with the Image Color Picker.

    Free RGB to HEX Color Converter: Fast, Accurate and Private

    Our free RGB to HEX converter was built to give designers, developers and students a simple and trustworthy way to turn RGB colors into HEX codes. Enter a color, pick it visually or adjust it with sliders, then copy exact HEX, short HEX, HEX with alpha, RGB and HSL values, test contrast, explore shades and harmonies, and convert lists of colors in bulk, all on one page. There is no signup, no limit and no data leaving your device.

    Ready to start? Scroll back up, enter your RGB color and copy the HEX code in seconds. If you work with colors often, explore the other free color tools on our site to convert between more color formats and build complete palettes.

    ADVERTISEMENT
    Demo Ad 300 x 250
    COMMON QUESTIONS

    RGB to HEX Converter FAQ

    Quick answers about converting RGB to HEX, using alpha transparency and getting accurate color codes.

    How do I convert RGB to HEX?

    Type or paste your RGB color, for example rgb(38, 98, 217), into the converter, or use the red, green and blue sliders or the color picker. The HEX code, #2662D9 in this example, appears instantly. Press Copy to use it in your CSS, design tool or document. It is free and needs no signup.

    What is the formula to convert RGB to HEX?

    Convert each of the red, green and blue values, which range from 0 to 255, into a two-digit hexadecimal number. To do this, divide the value by 16 to get the first digit and use the remainder as the second digit, replacing 10 to 15 with the letters A to F. Then join the three pairs after a hash symbol. For example, 38, 98 and 217 become 26, 62 and D9, which gives #2662D9.

    Can I convert RGBA or RGB with opacity to HEX?

    Yes. Set the alpha slider or include an alpha value in your input, such as rgba(255, 87, 51, 0.5) or rgb(255 87 51 / 50%). The converter returns an eight-digit HEX code, #FF573380 in this case, where the last two digits are the alpha. This is the web order (RRGGBBAA). Android uses AARRGGBB, so move the last two digits to the front for Android projects.

    Which RGB formats can I paste, and what happens if a value is above 255?

    You can paste classic rgb() with commas, the modern space-separated syntax, rgba() with alpha, the slash alpha syntax, percentage values and plain numbers such as 38 98 217. RGB channels only go from 0 to 255, so a larger number is limited to 255 and a negative number is limited to 0. If a value cannot be understood at all, the converter shows a message so you can correct it.

    What is the difference between RGB and HEX color codes?

    RGB and HEX store exactly the same information. RGB writes the red, green and blue amounts as three decimal numbers from 0 to 255, while HEX writes the same three amounts as a compact six-digit hexadecimal code. Because they describe the same color, converting between them never changes how the color looks. HEX is shorter and easier to copy, which is why it is so popular in design tools and CSS.

    What is a short HEX code, and can every RGB color use one?

    A short HEX code uses three digits instead of six, for example #FFF instead of #FFFFFF. Each digit is doubled to get the full code, so it only works when each channel has two identical digits. For example, rgb(255, 102, 0) is #FF6600, which can be written as #F60. Most colors cannot be shortened, and the converter shows a short HEX only when it matches your color exactly.

    Is this RGB to HEX converter free and safe to use?

    Yes. The converter is completely free, needs no account and has no limit on how many colors you can convert. All calculations happen inside your browser, so the colors you enter are not uploaded, saved or stored on our servers.

    ADVERTISEMENT
    Demo Ad 320 x 50