HEX to RGB

Turn hex colour codes into RGB values, a whole list at a time.

Runs on your deviceDesign & ColorWorkingNo account needed

What this tool does

HEX to RGB reads each line of your input as a colour and writes the equivalent sRGB triplet. Shorthand is expanded the way CSS expands it, by doubling each digit, so #fff becomes rgb(255, 255, 255) and #10B98180 keeps its alpha. The leading hash is optional for 3, 4, 6 and 8 digit codes, which means a value copied out of a spreadsheet or a Sass variable converts without being tidied up first.

The input is deliberately wider than the tool's name. Alongside hex it accepts the 148 CSS colour names, the keyword transparent, and rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() and color(srgb …) notation — so a stylesheet you are auditing can be pasted as it stands rather than filtered first. Up to 200 colours convert in a run; a longer list is refused with a count rather than silently truncated, and lines starting with // or a hash followed by a space are skipped, which lets you label sections of a palette.

Results come back in two parts. First a grid of swatch cards, one per line, each showing the colour itself, the text you typed and the value it converted to, so a wrong paste is obvious at a glance. Beneath it sits the table those cards are drawn from: Input, RGB, and R, G, B and Alpha as separate numbers, one row per colour. The output panel is narrow, so the last of those columns may need a sideways scroll. Copy output stays deliberately plain — the converted values only, one to a line, without the input column — because that is the form you paste back into a stylesheet.

Two things are worth knowing before you trust a number. Alpha from an 8-digit hex is a byte, not a fraction: the pair 80 is 128/255, which this colour converter reports as 0.502 rather than 0.5, and the same holds for every byte that is not a multiple of 51. And everything here is treated as sRGB — there is no colour management, so a hex lifted from a Display P3 document is read as though it were sRGB, and a lab() or oklch() value outside the sRGB gamut is clamped channel by channel rather than gamut-mapped, which can come back visibly flatter than the colour you started with. The conversion runs in this browser tab; the list is not uploaded, and the page keeps working with the network off.

How to use it

  1. Paste your codes, one to a line. Hex with or without the hash, 3, 4, 6 or 8 digits. Blank lines are ignored, and so are lines beginning with // or a hash and a space, so a palette can carry headings.
  2. Choose the output notation. Legacy rgb(59, 130, 246) for broad support, modern rgb(59 130 246) for CSS Color 4, bare 59, 130, 246 for pasting into code, or percentages at two decimal places.
  3. Decide what happens to alpha. Include it only for translucent colours, always, or never. In legacy notation an included alpha switches the function to rgba(); modern and percentage output use the slash form, and bare values append a fourth number.
  4. Scan the swatches, then read the table. Every card pairs the rendered colour with the line you typed and the converted value, so a wrong paste is obvious at a glance, and the table under the grid gives the same colours as numbers — Input, RGB, R, G, B and Alpha. Copy output puts the converted values on the clipboard, one to a line, without the input column.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Building an rgba() overlay from a brand hex

A scrim or a shadow needs the channels separated so opacity can be set independently of the colour it came from.

Filling in a design token table

Token documentation usually lists both notations. Converting the hex column in one pass keeps the RGB column consistent with it.

Moving a palette out of CSS

Android, OpenGL, canvas code and most plotting libraries want channel numbers, not hex strings. The bare values notation drops straight in.

Checking what a colour name resolves to

A stylesheet inherited with rebeccapurple or lightslategrey in it converts alongside the hex codes, so the whole list ends up in one comparable form.

Questions

Does the list of colours leave my machine?
No. The parsing and the arithmetic happen in this browser tab, so nothing is sent anywhere and the tool still converts with the network disconnected.
What does #fff convert to?
rgb(255, 255, 255). Three and four digit codes are expanded by doubling each digit, exactly as CSS does, so #fff is #ffffff and #f00a is #ff0000aa.
Why is my alpha 0.502 and not 0.5?
An 8-digit hex stores alpha as one byte from 00 to ff. The pair 80 is 128, and 128 divided by 255 is 0.50196, shown rounded to three decimal places. Only the six bytes that are multiples of 51 — 00, 33, 66, 99, cc and ff — land on 0, 0.2, 0.4, 0.6, 0.8 and 1 exactly; every other byte is an approximation of the fraction you had in mind.
Can I paste rgb() values or colour names instead of hex?
Yes. Colour names, transparent, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() and color(srgb …) are all read, so a mixed list from a stylesheet converts without being sorted first. Keep the function around the numbers, though: bare channels such as 59, 130, 246 are rejected, and the space-separated form 59 130 246 is worse — the spaces are stripped, 59130246 reads as an 8-digit hex, and you get a plausible but entirely wrong colour with no warning.
Where are the separate R, G and B columns?
In the table directly under the swatch grid: each row carries the input, the converted rgb() value and then R, G, B and Alpha on their own. The output panel is narrower than the six columns, so the last ones may sit off the right edge until you scroll the table sideways. If you would rather have the three numbers as text you can paste, the bare values notation writes them straight to Copy output.
It rejected my code for having five hex digits — why?
Only 3, 4, 6 and 8 digit codes are valid; five usually means a digit was dropped or an extra one typed. When the code carries a leading hash the error names the count it found, so you can see which of the two happened. Without the hash a five-digit string is not recognised as hex at all, and the message is the generic one about not being able to read the value.
Does it understand wide-gamut colour?
No. Every value is treated as sRGB and there is no ICC profile handling, so a hex taken from a Display P3 document converts as an sRGB colour. An lab() or oklch() input beyond the sRGB gamut is clamped per channel, not gamut-mapped, and nothing on the page flags that it happened.
I have more than 200 colours — what happens?
The run stops and tells you how many lines it counted. Split the list and convert it in batches; the cap keeps a mispaste from locking up the tab. Blank lines and comment lines are dropped before the count, so only real colours use up the allowance.
Can it pull the hex out of an image or a screenshot?
No, this takes typed or pasted text only. Image Color Picker samples a pixel from a file, and Extract Palette pulls a set of colours out of one.

Related tools