Cybrkyd's git repositories

unused-css

Branch: main Last commit: 2025-08-02 21:22:58 +0100 Clone: git clone https://git.cybrkyd.com/repository/unused-css

Find unused CSS with Python

A Python script to find unused CSS classes.

Requirements

Install it with:

pip install cssutils

Running

In def main(), edit the paths:

    html_directory = '/path/to/html/dir'
    css_files = [
        '/path/to/css/styles.css',
        '/path/to/css/bootstrap.css'
    ]

Then execute the script. The report with name unused_css_report_{timestamp}.txt is output in the same folder where the Python script is run from.

See also

The blog post: Find unused CSS with Python

Licence

This project is made available under a GPL3 licence -- see COPYING for the full text.