CSS Hex Shorthand Expander

Expand 3-digit CSS hex shorthand (#F80) to full 6-digit form

Expand 3-digit CSS hex shorthand like #F80 to its full 6-digit #FF8800 form by doubling each digit, with support for 4-digit alpha shorthand. Validates input and shows a live swatch. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does hex shorthand expansion work?

Each single digit is doubled. A 3-digit hex #F80 becomes #FF8800 because F becomes FF, 8 becomes 88, and 0 becomes 00. The same rule applies digit by digit, so the shorthand and full forms always represent the exact same color.

Expand CSS hex shorthand

CSS lets you write a hex color in a compact 3-digit form, where #F80 is exactly the same color as #FF8800. This tool expands that shorthand — and the 4-digit alpha variant #RGBA — into the full canonical form by doubling each digit, validates the input, and previews the result with a live swatch. It is the quick way to normalize colors before storing or comparing them.

How it works

Expansion is a simple per-digit doubling: every single hex digit is repeated to form a byte. So #F80 expands as F to FF, 8 to 88, 0 to 00, giving #FF8800. The same rule applies to the 4-digit alpha shorthand, where the fourth digit becomes the alpha byte: #F80a becomes #FF8800AA. The tool first strips an optional leading hash, checks that the body is valid hex and a legal length (3, 4, 6, or 8), then either expands the short forms or passes the already-full forms through unchanged.

A table of representative expansions

ShorthandExpandedWhat you see
#000#000000Black
#fff#ffffffWhite
#f00#ff0000Pure red
#0f0#00ff00Pure green
#00f#0000ffPure blue
#abc#aabbccSlate blue-grey
#F80#FF8800Orange
#0f08#00ff0088Semi-transparent green

Notice that shorthand can only represent 16 steps per channel (0, 1, 2 … up to F), which is why only a limited subset of colors can be expressed in three digits. Any color whose channels do not divide evenly into “digit doubled” values — for example #3b82f6 (a popular blue) — has no valid shorthand form.

Why the rule is doubling, not padding

A common mistake is to assume #F80 expands to #F08000 (padding with zeros). That would be wrong — it would change the color. The CSS specification defines shorthand as “doubling each digit” because that preserves proportionality.

For the red channel:

  • F in hex = 15 in decimal, which is the maximum single digit
  • FF in hex = 255 in decimal, which is the maximum byte

Doubling F to FF maps the maximum single-digit value to the maximum byte value. Padding with zero would give F0 = 240 in decimal — a lighter red, not the intended maximum red.

The doubling rule: digit × 16 + digit = digit × 17. So A (10 decimal) becomes AA = 10 × 17 = 170. 5 becomes 55 = 5 × 17 = 85.

When this tool is useful

  • CSS refactoring: You have a codebase mixing shorthand and full-form hex and want to normalize everything to 6-digit before passing to a color parser.
  • Comparing colors: Two hex values can look different in string form but be the same color (#fff and #ffffff). Expanding both before comparison catches this.
  • Design token pipelines: Build tooling that processes design tokens often requires consistent 6- or 8-digit hex input; running shorthand through this expander cleans the input automatically.
  • Quick validation: The tool validates whether a hex string is legal CSS before you attempt to use it in code, flagging bad lengths or non-hex characters immediately.

#abc expands to #aabbcc, and #0f08 expands to #00ff0088. Everything runs in your browser — no data is sent anywhere.