A browser-based CSS analysis and optimization tool. Paste (or drag-and-drop) a CSS file and run one or more analyzers to detect redundancies, normalize colors, merge duplicates, and more.
Try it online — no install needed.
- Empty Rules — Detects and removes selectors with no declarations
- Color Normalization — Converts colors to a consistent format (hex, rgb, hsl)
- Duplicate Detection — Finds identical declaration blocks across selectors
- Media Query Merging — Consolidates duplicate
@mediablocks - Fuzzy Value Matching — Spots near-identical numeric values (e.g.
14pxvs15px) - Near-Duplicate Analysis — Detects selectors that share most declarations
- Design Tokens — Extracts repeated values as CSS custom property candidates
- Single textarea — edits are applied in-place via the Apply button
- Auto-Refine loops the safe analyzers (empty rules, color normalize, duplicates, media queries) until the CSS stabilizes
- Drag-and-drop
.cssfiles directly onto the textarea - Download or copy the result at any point
- Light / dark theme toggle
- English / French interface (i18n via PHP + JSON)
- PHP 7.4+ (used only for i18n bootstrapping)
- A web server (Apache, Nginx, Caddy…) with PHP support
- No database, no Composer dependencies, no build step
git clone https://github.com/Sangiovanni/CSS-refiner.gitIf you want to rename folders or nest the app under a URL prefix, run the interactive setup script:
# Linux / macOS
chmod +x setup.sh
./setup.sh
# Windows
setup.batThe setup script lets you:
- Rename
public/to match your vhost (e.g.www,public_html) - Rename
secure/for obscurity (e.g.backend,engine) - Set a URL space to serve the app from a subdirectory (e.g.
tools/css→http://domain/tools/css/)
All three constants in init.php are updated automatically. You can re-run the script at any time.
If you don't need any of this, skip straight to step 3.
The web server's document root must point to the public folder (or whatever you renamed it to). The secure folder sits outside the document root and is never accessible via HTTP — this is intentional.
css-refiner/
public/ ← document root points HERE
index.php
init.php
assets/
secure/ ← outside document root (not web-accessible)
cssrafiner/
src/
translate/
<VirtualHost *:80>
ServerName cssrefiner.local
DocumentRoot "/path/to/css-refiner/public"
<Directory "/path/to/css-refiner/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>server {
listen 80;
server_name cssrefiner.local;
root /path/to/css-refiner/public;
index index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}127.0.0.1 cssrefiner.local
http://cssrefiner.local/
That's it — no build step, no dependencies to install.
Use the setup script (step 2) or manually set the PUBLIC_FOLDER_SPACE constant in public/init.php. This nests the app under a subdirectory so it doesn't conflict with your existing site:
your-existing-site/
public/ ← your existing document root
index.html ← your homepage
tools/ ← CSS Refiner lives here, isolated
index.php
assets/
For example, set PUBLIC_FOLDER_SPACE to 'tools' and move the app files into public/tools/. The setup script handles this automatically.
public/
index.php — Entry point, HTML template
init.php — Path constants, bootstrap
assets/
css/style.css — All styles (light + dark theme)
js/
app.js — Main orchestration (events, pipeline, apply)
constants.js — Tool identifiers, config values
css-parser.js — Character-by-character CSS parser
i18n.js — Client-side translation helper
utils.js — Shared utilities
analyzers/
color-normalize.js — Color format normalization
design-tokens.js — Repeated value extraction
duplicates.js — Identical block detection
empty-rules.js — Empty selector removal
fuzzy-values.js — Near-identical value matching
media-queries.js — @media block consolidation
near-duplicates.js — Similar selector detection
ui/
components.js — Reusable UI components
diff-view.js — Before/after diff rendering
results-panel.js — Suggestion list and controls
secure/cssrafiner/
src/Translator.php — PHP i18n class
translate/
en.json — English translations
fr.json — French translations
This project was built entirely through AI-assisted development using GitHub Copilot (Claude). The human provided architecture rules, feature direction, code review, and bug reports. The AI generated all implementation code.
See DEVELOPMENT.md for the full narrative of the development process.
If you find this useful:
MIT — see LICENSE for details.
