HEX shorthand expander —

Paste HEX colour codes to expand shorthand such as

Live demo · real result from this tool
Output

Result

#fc0#aabbcc#3b82f6  (no exact shorthand (nearest #38e))#1234

Table

Input6/8-digit3/4-digitNote
#ffcc00#ffcc00#fc0Collapsible
#abc#aabbcc#abcCollapsible
#3b82f6#3b82f6no exact shorthand (nearest #38e)Each pair must repeat a digit
#11223344#11223344#1234Collapsible

Processed on your device — nothing is uploaded.

How to use the HEX shorthand expander

  1. Paste your codes into HEX codes (one per line). Spaces, commas and semicolons also separate codes.
  2. Choose an Output: Toggle each (expand short codes, shorten long ones), Expand all or Shorten where possible.
  3. Copy the Result list.
  4. Check the table for each input’s long form, short form and a note on why a code could or could not be shortened.

What it does and when to use it

Short HEX codes save a few characters in CSS but cause problems elsewhere. Some design tools, spreadsheets and colour pickers only accept six digits. Going the other way, minifying a stylesheet or matching a team style guide sometimes calls for the short form. This tool converts a whole list in one go and flags anything that is not a valid HEX code.

Use it when moving colours between CSS and other tools, when tidying a stylesheet, or when you want to know if a brand colour has a shorthand. If you need the RGB numbers too, the colour converter gives every notation. For 8-digit codes with alpha, the HEX to RGBA converter explains the alpha pair, and RGB percentage gives 0–1 values for code.

How it works

Each item is matched against 3, 4, 6 or 8 hex digits, with an optional #. Other lengths, such as 5 digits, are marked “Not a hex colour”.

  • Expand: every digit of a 3- or 4-digit code is doubled.
  • Shorten: the long code is split into pairs. If every pair is a repeated digit (ff, cc, 00), the first digit of each pair is kept.
  • Nearest: each pair’s value is divided by 17 and rounded, because shorthand steps are 17 apart (00, 11, 22 … ff).

Toggle each expands codes of 3 or 4 digits and shortens codes of 6 or 8.

Worked examples

These are the tool’s own results.

Expand. #abc becomes #aabbcc.

Shorten. #ffcc00 becomes #fc0. #3b82f6 cannot be shortened; the tool reports no exact shorthand (nearest #38e).

Toggle the default list. #ffcc00 → #fc0, #abc → #aabbcc, #3b82f6 stays long, and the 8-digit #11223344 shortens to #1234, alpha included.

Limits and tips

  • Shortening never changes a colour. If a code has no exact shorthand, the long form is kept with a note.
  • CSS names, rgb() and other notations are not converted here; they are reported as not hex.
  • Processing happens in your browser.

Frequently asked questions

How does HEX shorthand work?
In a 3-digit code each digit is doubled.
Which colours can be shortened?
Only those where each pair of digits repeats one digit, such as
What is the "nearest" shorthand?
For a colour with no exact shorthand, the tool rounds each channel to the nearest repeated pair. For
Does the
No. The tool accepts codes with or without
Is shorthand safe in CSS?
Yes. 3-, 4-, 6- and 8-digit HEX colours are all part of CSS Color Module Level 4 and work in current browsers. Some other programs only read 6-digit codes, so expand before pasting into those.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close