Free online text tool

Extract Hex Colors

Extract Hex Colors finds every hex color code in your CSS or text and lists each one on its own line. Paste your code, click the button and copy the result. It is free and runs in your browser.

Extract Hex Color Code Tool

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Hex Color Extract Example

Before
background: #fff;
color: #2c7be5;
margin: 0 auto;
After
#fff
#2c7be5

Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.

Suggest a New ToolProvide Feedback on This Tool

What does Extract Hex Colors do?

This tool finds the hex color codes in your CSS or text and puts each one on its own line. Everything else is removed from the result.

A hex color code starts with # and has 3, 4, 6 or 8 hex digits, like #fff or #2c7be5. The 4 and 8 digit forms include a transparency value. A # followed by anything else, such as #12345 or an HTML entity like ', is skipped.

Use it to collect the colors of a stylesheet, build a palette, or check which colors a design uses. Repeated codes can be listed once.

Extract hex colors examples

Each example shows the CSS or text before and after extracting. Duplicates are removed unless the option is off.

CaseBeforeAfter
CSS example
background: #fff;
color: #2c7be5;
margin: 0 auto;
#fff
#2c7be5
Several codes in one line
Colors: #FF5733, #33FF57 and #3357FF
#FF5733
#33FF57
#3357FF
Codes with alpha (8 digits)
overlay: #00000080;
#00000080
No # sign is skipped
color ff0000 and #ABC
#ABC
Not a color code is skipped
Issue #12345, #abcdefg and #1a2b3c
#1a2b3c
Duplicates removed
#fff #FFF #000 #fff
#fff
#000
Duplicates kept (option off)
#fff #000 #fff
#fff
#000
#fff

How to extract hex color codes from CSS or text

  1. 1
    Add your CSS or text
    Paste your CSS or text into the box, or import a text file.
  2. 2
    Choose duplicates
    Keep Remove duplicate colors ticked to list each code once, or untick it to keep every match.
  3. 3
    Click Extract Hex Colors
    Every hex color code is found and put on its own line. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the list where you need it.

When to extract hex colors

Good for

Listing the colors used in a stylesheet or theme file, building a palette, comparing a design with its code, and cleaning up colors before a redesign.

Check first

Only codes that start with # are found. Colors written as rgb(), hsl() or a name such as red are not included, and the result replaces your text, so use Undo if you need the original.

Other tools

To see a color try Hex Code Visualizer. To make new colors try Random Color Generator.

Extract hex colors FAQ

What does the Extract Hex Colors tool do?

It finds every hex color code in your CSS or text, such as #fff or #2c7be5, and puts each one on its own line. Everything else is removed from the result.

How do I extract hex color codes from CSS?

Paste your CSS or text, or import a text file, then click Extract Hex Colors. The codes replace the text in the box. Click Copy to use them, or Undo to go back.

Which hex color formats are found?

Codes that start with # and have 3, 4, 6 or 8 hex digits (0-9 and a-f), for example #fff, #ffff, #2c7be5 and #2c7be580. The last two forms include an alpha (transparency) value.

Does it find colors written without the # sign?

No. A code must start with #. A plain ff0000 or a color name such as red is not matched.

Does it remove duplicate colors?

Yes, by default. A code used more than once is listed once, and #FFF and #fff count as the same code. Untick Remove duplicate colors to keep every match.

Are things like #12345 or HTML entities skipped?

Yes. A # followed by a number of digits that is not 3, 4, 6 or 8, or by letters outside a-f, is not a color code, and entities such as ' are ignored.

What if my text has no hex color?

The text is left as it is and you see the message No hex color codes found.

Is this tool free and is my text private?

Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.

Looking for more text tools?

Browse Extract Tools

Last updated: 8 November 2026