Toolivaro

Free Hex to RGB Converter

Convert hex color codes to RGB triplets and back — instantly, with 3- and 6-digit shorthand support, fully local.

The hex-to-RGB converter translates between the two color notations every front-end developer meets: #3498db-style hex codes and rgb(52, 152, 219) triplets. Type or paste either form and the tool fills in the other — 6-digit hex becomes its three channel values, and a comma- or space-separated triplet becomes its hex code. The converter accepts 3-digit shorthand (#fff expands to #ffffff), optional leading #, uppercase or lowercase digits, and even the full rgb(52, 152, 219) function syntax, so values copied out of a browser inspector, a design tool, or a mockup all work as pasted. Validation is strict about what a color can be: hex digits must be valid, and each RGB channel must be an integer from 0 to 255 — a triplet like 300, 0, 0 is rejected with a clear message instead of silently wrapped or clamped. When both fields are filled, the hex value wins, so the precedence is predictable and documented rather than surprising. The conversion is pure arithmetic on the channel values — nothing is approximated, and nothing you enter is uploaded, logged, or stored. Use this tool when a style guide gives you hex and your charting library needs RGB, when you are debugging a color that looks different than expected in a dark theme, or when you want to reason about how much red, green, and blue actually make up a color.

Processed locally in your browser

3 or 6 digits with an optional leading # — uppercase or lowercase.

Three integers from 0 to 255, separated by commas or spaces.

How to use this calculator

What the two notations mean

Hex and rgb() are two spellings of the same thing: three channel values that say how much red, green, and blue a color mixes. A hex code like #3498db is the three channels written in base 16 — the pairs 34, 98, db — while rgb(52, 152, 219) writes the same numbers in decimal. The converter is pure arithmetic on those channels: each hex pair is parsed with parseInt(·, 16) and each decimal channel is converted back to two base-16 digits, so the two forms are always exact, never approximated.

That is the tool’s entire job, and it is why the conversion is instant and lossless: #3498db is rgb(52, 152, 219), and rgb(52, 152, 219) is #3498db, with nothing lost in either direction. The hex form is the compact notation style guides and design systems use; the rgb() form is what many charting libraries, canvas APIs, and older CSS code expect.

The input forms that just work

Values copied out of a browser inspector, a design tool, or a mockup arrive in different shapes, and the converter accepts them as pasted: a 6-digit code, a 3-digit shorthand like #fff (which expands to #ffffff, matching CSS behavior), an optional leading #, uppercase or lowercase digits, and even the full function syntax rgb(52, 152, 219) or a bare triplet 52, 152, 219. Output is always normalized to the unambiguous 6-digit lowercase hex form, so the result never carries the ambiguity of shorthand.

Validation is strict about what a color can be: hex digits must be valid hex, and each RGB channel must be an integer from 0 to 255. A triplet with a channel of 300 is rejected with a clear message rather than silently clamped — CSS clamps out-of-range values, but a conversion tool should not invent a color the input did not describe.

Why the precedence rule exists

When both fields are filled, the hex value wins and converts to RGB; the rgb field is ignored. The rule is documented rather than guessed because a converter that silently picked a side would produce a result that disagreed with what the user intended to change. The behavior is predictable: edit the field you want to be authoritative, and the other side updates to match.

The same predictability applies to case and formatting: hex output is always lowercase because hex digits are case-insensitive and lowercase is the convention most tooling and minifiers use, and shorthand input always expands to the full form so the result is unambiguous.

The honest limits

The converter handles three-channel colors only: 4- and 8-digit hex (#rgba, #rrggbbaa) and rgba() carry an alpha channel this tool does not parse, and named CSS colors (red, blue, rebeccapurple) are not accepted — convert those by looking up their hex or rgb form first. For colors with transparency, convert the 6-digit base color here and keep the alpha separately. And as with everything on the site, the conversion runs entirely in your browser: no value you enter is uploaded, logged, or stored.

How is the result calculated?

A design-tool hex value in your charting library

Your design system defines the brand blue as #3498db, but the charting library takes rgb() triplets. The converter splits the hex into its pairs — 34, 98, db — and parses each in base 16: 52, 152, 219, so the chart receives rgb(52, 152, 219) and renders the same blue.

Example input and output
Input Value
hex #3498db
rgb
Result rgb(52, 152, 219)

What is the formula and its assumptions?

Hex to RGB

rgb(r, g, b) = hex pairs parsed in base 16

Formula terms
Symbol Meaning
hex pairs the three two-digit groups of a 6-digit hex code (RRGGBB), each parsed with parseInt(·, 16)
r, g, b channel values from 0 to 255

3-digit shorthand (#fff) expands each digit before parsing, matching CSS behavior.

RGB to Hex

hex = #rrggbb, each channel in two lowercase base-16 digits

Formula terms
Symbol Meaning
channel an integer from 0 to 255
rr gg bb the two-digit hexadecimal renderings, zero-padded (e.g. 10 → 0a)

What are the most common mistakes?

  • Writing out-of-range channels (like 300) and expecting clamping — CSS clamps, but the converter rejects with an error, which is the honest behavior for a conversion tool.
  • Forgetting that a single-digit hex channel expands (e.g. #f00 is #ff0000, not #00ff00) — the converter always outputs the expanded form.
  • Entering named colors (red, blue) — the converter only accepts hex digits and numeric triplets.

What are the assumptions and limitations?

  • No alpha channel: 4- and 8-digit hex and rgba() are not supported.
  • Named CSS colors (red, blue, rebeccapurple) are not accepted — use their hex or rgb forms.
  • Hex output is always lowercase and 6-digit, normalizing whatever form you entered.

Where do the numbers come from?

Last reviewed August 11, 2026 · Version 1.0.0 · Toolivaro does not guarantee external content.

Frequently asked questions

What is the difference between 3-digit and 6-digit hex?

A 3-digit code like #fff is CSS shorthand: each digit doubles, so #fff means #ffffff. It is supported by every modern browser. The converter accepts both and always outputs the full 6-digit form, so the result is unambiguous.

Do you handle alpha (transparency) values?

Not yet. 8-digit hex (#rrggbbaa) and rgba() carry a transparency channel that this converter does not parse. For colors with alpha, convert the 6-digit base color here and keep the alpha separately.

Why is the hex output lowercase?

Hex digits are case-insensitive — #3498db and #3498DB are the same color. Lowercase is the convention used by most modern tooling and minifiers, and it keeps the output consistent for copy-paste.

What happens if I fill in both the hex and RGB fields?

The hex value wins and converts to RGB; the RGB field is ignored. The tool documents this precedence rather than guessing, so the result is always predictable.

Why is #fff the same color as #ffffff?

CSS 3-digit shorthand doubles each digit: #fff means #ff ff ff, which is exactly #ffffff. The converter accepts both and always outputs the expanded 6-digit form, so the result is unambiguous.

Is 300, 0, 0 ever a valid color?

No — each channel must be an integer from 0 to 255. CSS clamps out-of-range values silently; this converter rejects them with an error instead, because converting a value that was not a color would produce a misleading result.

Part of Format and conversion tools

Found a mistake or have a correction? Report it — we review every correction.

Was this helpful?

Reviewed by the Toolivaro editorial team per our methodology Methodology · Editorial policy