How to use the HEX shorthand expander
- Paste your codes into HEX codes (one per line). Spaces, commas and semicolons also separate codes.
- Choose an Output: Toggle each (expand short codes, shorten long ones), Expand all or Shorten where possible.
- Copy the Result list.
- 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?
Which colours can be shortened?
What is the "nearest" shorthand?
Does the
Is shorthand safe in CSS?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.