Hex to RGB Converter

Convert a hex colour into an RGB colour, or vice versa.

advertisement

Hexadecimal Colour Conversion

This converter runs a simple JavaScript algorithm which converts a hexadecimal number into an RGB colour in standard web colour format. For example, the colour "#000000" which represents the colour black in hex-format will be translated into its RGB format: "rgb(0,0,0)".
Let's step through a simple example of generating an RGB colour from a hex colour:
  1. Starting with the colour "#de5521", we first remove the "hash" sign. This is just to signify that the following 6 numbers represent a hex colour.
  2. So now we've got "de5521". Next, we break this string into 3 parts: {d3, 55, 21}.
  3. Now, the first part represents how much red is in the colour, the second represents how much green and the third, how much blue. Even though they have letters in them, each of these parts actually represents a number, but in a form known as "hexadecimal".
  4. To get the RGB form, we need to be able to convert hexadecimal into decimal. Luckily, that's a very simple operation in most programming languages (see previous link for JavaScript snippet).
  5. Each of the three hexadecimal numbers are thus turned into decimal numbers giving us: {222,85,33}.
  6. These are are red, green and blue values respectively! We can wrap them into rgb notation as follows: rgb(222,85,33).
Converting a RGB colour into a hex colour (the reverse direction) is as simple as following the above steps in reverse.

LingoJam © 2025 Home | Terms & Privacy