RGB to Hex Converter

Try RGB to HEX

Display choices apply to the result. Use a decimal point in numeric inputs and follow each text field's separator instructions.

RGB to HEX inputs

Loading calculator. If this message stays visible, enable JavaScript and reload.

The RGB to hex converter turns three decimal red, green and blue channel values into a six-digit hexadecimal colour. Enter a whole number from 0 to 255 in each field. For red 29, green 66 and blue 122, the result is #1D427A. Use the value where your stylesheet, design editor or token library expects #RRGGBB.

Keep the channel order and scale from your source. This form takes decimal channel values for an sRGB colour and produces an uppercase code with a leading hash. Preview the colour in the receiving software if the handoff includes transparency, a different source colour space or a design that depends on the surrounding background.

Building a six-digit hex code from three RGB channels

What does the RGB to hex converter create?

The RGB to hex converter builds one two-digit hexadecimal pair for each input. Red goes first, green second and blue third. The form keeps leading zeros, uses the letters A through F in uppercase, and prefixes the six digits with #. This gives a code in the familiar six-digit notation even when one or more channels have small values.

Use the output when a library requests a colour token or a design editor only exposes a hex field. For example, you could copy the RGB values from the properties of a designed object and store the converted code next to the token name in a handoff document. Each pair is still traceable to its own field. The conversion does not decide which colour is appropriate for a button, heading or background.

A hex value also makes comparison easy in a source file. If an implementation appears to have one channel different from the source, compare the corresponding pair. This is more precise than deciding from a screenshot whether two shades look similar. Keep the original numbers and an example of the expected use in the review notes.

How do I enter channels correctly?

  1. Find the red, green and blue numbers in the source. Verify that they are whole values on the 0–255 scale.
  2. Enter them in Red (0–255), Green (0–255) and Blue (0–255), matching each channel by name.
  3. Select Calculate / Run and review the six-digit result. Copy the leading hash when the receiving field uses CSS hex notation.
  4. Enter the result in the intended editor or token and preview it in the actual state where it will be used.

If the source shows a complete value such as rgb(29, 66, 122), enter its numbers into the three separate fields. CSS-style punctuation and the function name belong outside the numeric inputs. Fill all three fields, including zeros. A missing channel is an incomplete input, while zero is a valid channel value.

Check the unit and colour space before entering values taken from an image library. A program may expose normalized values, percentages or channels from another profile. Three valid integers can still describe a different colour when the source scale or space was read incorrectly. Use documentation for the source to determine what calculation, if any, is required before this step.

When transferring a full palette, read the properties for one selected colour at a time. A design might display the channels for a fill or a stroke under the same panel name. Record which property you chose so the output goes to the matching token. This prevents the conversion from accidentally representing a border colour when the handoff asked for the surface colour.

Keep the field labels when pasting the source into your review sheet. Three integers copied without context can look like a version, a size or an alternate colour model. Put R, G and B above the values and link the row to the original swatch. Mark whether the values describe the rendered effect or an unblended colour before someone reuses the six-digit code. A correctly computed hex string can still be applied incorrectly if the source's purpose was lost between tools.

How does the worked example convert the decimal values?

For each channel, divide its decimal integer by 16. The whole quotient gives the first hex digit and the remainder gives the second. Values 10 through 15 use A through F. For red 29, green 66 and blue 122, the calculations work as follows.

ChannelDecimalQuotient and remainderReturned pair
Red291 × 16 + 131D
Green664 × 16 + 242
Blue1227 × 16 + 107A

Reading the pairs in channel order gives #1D427A. The remainder 13 appears as D and the remainder 10 appears as A. For a manual check, take one pair and multiply its first digit's value by 16 before adding the second. This reverses the arithmetic and returns the channel number you entered.

Try the same method with 255, 165 and 0. The first value is 15 × 16 + 15, giving FF. The second is 10 × 16 + 5, giving A5. Zero gives 00. The finished value is #FFA500. Notice that the colour code still ends with two digits even when its blue channel is zero.

Why does padding each channel to two digits matter?

Each pair occupies a fixed position in the final string. For example, red 8, green 16 and blue 32 return #081020. Red uses 08, green uses 10 and blue uses 20. If you omit the first zero in the red pair, the remaining five digits do not have the structure of a six-digit colour.

At the bottom of the range, three zeros produce #000000. At the top, three 255s produce #FFFFFF. Use those cases to check a pipeline that stores hex values in a spreadsheet or text file. Storing a colour as numeric data can cause leading digits or letters to be changed by formatting. Keep it as text if the target depends on exact notation.

CSS also accepts some shorter colour spellings by duplicating each shorthand digit. That rule applies only to colours whose long-form pairs contain a repeated digit in each channel. The output here stays six digits. Keep the unambiguous full length when documenting a design handoff. The CSS Color Module Level 4 definition of hex colours describes both forms.

How should I handle fractions, out-of-range values or percentage channels?

Enter whole values from 0 to 255 inclusive. A value above 255 fails the range check, and a fraction such as 2.5 fails the whole-integer check. The tool does not silently round or clamp a source value. Correct the input or decide with the owner of the data how to quantize a high-precision source first.

A percentage describes a different numeric scale. A percentage value of 50 may represent the middle of a channel in a source system. Entering 50 in this form means the decimal integer 50 out of 255. Check the conversion and rounding requirements in the project before mixing these representations. If the colour comes from CSS, preserve its declared colour space and opacity while reading its values.

The source can also list estimated colours obtained by sampling an image. A sampled pixel may include antialiasing or effects from a semi-transparent layer. Use a named palette token or a filled area when your goal is to reproduce a design setting. If you are measuring the appearance of a pixel, record how and where it was sampled and use the sampled value with that context.

For an import check, compare a colour that uses both boundary values with one whose channels are all in the middle of the range. The checked #FFA500 result confirms the upper limit for red and lower limit for blue, while a blue from an actual design can exercise the channel order. Include a low channel such as the red 8 in #081020 to confirm that the import retains leading zeros. Those cases expose different kinds of errors in a destination that processes the code as text.

How can I cross-check the result before sharing it?

Use the hex to RGB converter on the returned six-digit code. The decimal values should match the original three integer channels. A case difference in a hex spelling usually represents the same colour. An extra hash, missing leading zero or reordered pair indicates a substantive transcription problem in the record you are comparing.

Verify the copied string in the destination as well. A CSS theme may expect a hash and uppercase letters may be optional, while another system may store the six digits separately from a format marker. The hex value is only one input to the destination. Apply it to the intended property and state, then compare the rendered view with your reference.

For a non-production test, take a swatch from the random colour generator, read its decimal channels and convert them back with this page. A round trip through both representations can catch errors when a team is setting up a process to store and compare colour tokens.

When the colours appear close, compare the channel values before using a visual match. A misplaced input might swap red and blue. The result can retain the right length and casing while describing a different colour. The original channel labels and the paired output give you a direct way to find the mistake. After correcting it, review the receiving component to confirm that it used the new code rather than an older inherited theme value.

What happens to alpha and other colour information?

The result contains red, green and blue. There is no alpha input. A colour with opacity carries a separate value that may affect how it looks over another colour. Store that value in whatever form your destination requires. An opaque appearance implied by #RRGGBB can be a deliberate output for the raw channels, while a design with transparency needs its own retained setting.

A wide-gamut or color-managed source may attach meaning beyond three channel integers. The same numbers in different colour spaces can produce different results. Convert the colour using the appropriate colour-management workflow before representing it as six-digit sRGB hex. Keep the source profile in the handoff notes if the destination may need to make that decision later.

For text and backgrounds, assess the colour pair in the position where it is used. The WCAG contrast checker can compare an opaque foreground and background represented by their supported hex values. You still need the actual text size and the relevant context for an accessibility review. Hex conversion supplies a format for the values, not a verdict about the design.

How should I record a colour for reuse across a product?

Use a stable identifier alongside the output. A handoff entry might specify the token name, red, green and blue inputs, the returned hex, the theme and its use. That context helps reviewers determine whether a future difference comes from updated values or from applying the code to the wrong state. Preserve an editable source rather than using a screenshot as the only record.

When comparing a visual issue between environments, record which theme and component state were visible. The viewport size checker helps report the CSS dimensions associated with a layout. The screen resolution checker covers reported screen dimensions separately. Choose the information needed to reproduce the visual issue and verify the colour value in the appropriate stylesheet or design file.

Repeat the comparison when a palette changes. Keep a record of which tokens retained the same channels and which ones were deliberately revised. This makes reviews of dark and light themes easier because the label for a use remains identifiable even when its code changes. Confirm the result with a sample from each important state.

Review removals as well as additions. A design handoff can mistakenly keep an old token in example code after the product palette has changed. List the current RGB values, the converted hex and the source location for each retained token. Mark any legacy swatch needed for backward compatibility with an existing asset. The records help someone decide which code to use for a new component without comparing colours by sight or relying on an old screenshot.

RGB to hex converter FAQs

Can I enter all three numbers in one field?

Enter each value separately in its labelled red, green and blue field. Use the order shown in the source to identify each value before copying it.

Why are the letters in the result uppercase?

The form uses uppercase to format the hex pairs. In CSS, the corresponding lowercase letters represent the same hexadecimal digits.

Will a zero be kept in the output?

Yes. A zero channel becomes 00. A small nonzero channel can also have a leading zero, so each channel always has two positions in the result.

Can the form convert opacity with the three channels?

It accepts red, green and blue. Preserve opacity separately when the receiving design or code needs alpha information.

Does this convert from CMYK or another colour space?

Provide the three whole RGB channel values the form expects. Use a separate color-managed conversion first when your original numbers describe a different space.

How can I confirm the copied code still describes the same channels?

Run the returned hex through the hex to RGB converter and compare each decimal value with the original input. Check the destination's colour interpretation separately.

What if my spreadsheet drops a leading zero?

Store the six-digit value as text with its leading hash when the destination supports that representation. If another system stores the digits alone, preserve all six positions. Compare the exported value with your recorded result before applying it.