get-colour-palette-from-codebase Svelte Themes

Get Colour Palette From Codebase

Python script to generate a HTML file showing all colour references used in a code repo, will scan for .js .ts .html .css and .svelte files

get-colour-palette-from-codebase

Generate an HTML “colour palette” report from a codebase by scanning for hard-coded colour literals.

The script recursively scans a directory for common colour formats (hex, rgb()/rgba(), hsl()/hsla()) in these file types:

  • .css
  • .js
  • .ts
  • .html
  • .svelte

It outputs a single HTML file showing swatches grouped by similar colours. Clicking a swatch opens a details panel listing every place that colour was found (file + line number + the full line of code).

Usage

Requirements

  • Python 3 (tested with python3)

Run

Scan a directory and write colour-palette.html in the current directory:

python3 generate_color_palette.py path/to/your/repo

Choose an output path/name:

python3 generate_color_palette.py path/to/your/repo --out ./colour-palette.html

Open the generated HTML file in your browser.

Notes

  • The scan skips common generated/vendor directories (e.g. node_modules, dist, build, .git, virtualenv folders).
  • If the output HTML is inside the directory being scanned, it’s automatically excluded so the report doesn’t include itself.

Top categories

Loading Svelte Themes