CSSupgrade
Keeping your CSS up to date with full browser compatibility.
Sponsors

Usage
CSSupgrade is safe and meant to be used automatically on your codebase.
We recommend integrating it into your development workflow using pre-commit, husky, or as an agent skill.
CLI
To try it out on a repository without writing changes, run:
npx -y cssupgrade $(git ls-files '*.css')
To transform code from standard input, pass - as the input path:
echo '.a { .b { color: red } }' | npx cssupgrade -
For help with available options:
npx cssupgrade --help
pre-commit
uvx pre-commit install
# .pre-commit-config.yaml
repos:
- repo: https://github.com/codingjoe/cssupgrade
rev: 2026.1.0 # Use the latest release
hooks:
- id: cssupgrade
pre-commit run cssupgrade --all-files
Husky
Assuming Husky is already initialized and .husky/pre-commit already contains set -e, append:
echo "git diff --cached --name-only --diff-filter=ACMR -z -- '*.css' | xargs -0 sh -c 'test \"\$#\" -eq 0 && exit 0; npx -y cssupgrade --write -- \"\$@\"' sh" >> .husky/pre-commit
echo "git diff --cached --name-only --diff-filter=ACMR -z -- '*.css' | xargs -0 sh -c 'test \"\$#\" -eq 0 && exit 0; git add -- \"\$@\"' sh" >> .husky/pre-commit
Agent Skill
CSSupgrade is available as a skill in Claude Code. The plugin is distributed via the codingjoe/claude-plugins marketplace. To use it:
- Run
/plugin marketplace add codingjoe/claude-plugins
- Run
/plugin install cssupgrade@codingjoe
The skill will analyze your selected styles and suggest transformations based on the Baseline browser support policy.
Browser Support & Baseline
All transformations are based on Web Platform Baseline features. Baseline tracks which web platform features are safe to use across browsers.
By default, CSSupgrade uses widely available features, meaning they work in all major browsers (Chrome, Edge, Safari, Firefox) for at least 30 months. This ensures full compatibility while keeping your styles modern.
You can opt into newly available features (available in all browsers for 0-30 months) with:
npx cssupgrade --baseline newly-available <files>
For more information about Baseline browser support, visit web.dev/baseline.
Supported File Types & Languages
Transformations
[!NOTE]
A transformation applies only to CSS that the parser accepts. Unknown at-rules
and invalid declarations stay unchanged.
Rules that cannot nest keep their original text.
Widely available
-.card {
- padding: 1rem;
-}
-.card .title { font-weight: bold; }
-.card:hover { color: red; }
+.card {
+ padding: 1rem;
+ .title { font-weight: bold; }
+ &:hover { color: red; }
+}
-input[type="text"] { color: black; }
-input[type="email"] { color: gray; }
+input {
+ &[type="text"] { color: black; }
+ &[type="email"] { color: gray; }
+}
Only adjacent rules are nested, so the cascade order stays the same.
Every child selector must repeat a parent selector or a shared selector prefix, and all parent selectors must have the same specificity.
Rules inside @media, @supports, @container, @layer, @scope, and @starting-style blocks are nested as well.
/* Not transformed - `@keyframes` children are keyframe selectors */
@keyframes fade {
from { opacity: 0 }
}
Selector lists → :is()
-.card .title, .card .body { color: red; }
+.card :is(.title, .body) { color: red; }
Newly available
No transformations are available yet.
Versioning
CSSupgrade uses the calver YYYY.MINOR.PATCH versioning scheme.
The year indicates the baseline version. New transformations are added in minor releases, while patches are reserved for bug fixes.
Related Projects
Thanks to esupgrade for inspiring CSSupgrade.
Distinction
esupgrade upgrades JavaScript and TypeScript syntax.
CSSupgrade applies the same Baseline policy to CSS.
License
CSSupgrade is licensed under the GNU Affero General Public License v3.0 or later, with Johannes Maron as copyright holder.
See LICENSE for the full license text.