Tailwhip
A pure Python Tailwind CSS class sorter that works with any HTML or CSS file, including Django templates and other template languages.
Example

Usage
$ uvx tailwhip --help
Usage: tailwhip [OPTIONS] [PATH]
Sort Tailwind CSS classes in HTML and CSS files.
Automatically discovers and sorts Tailwind classes according to
a consistent ordering. Supports HTML, CSS, and template files
with Tailwind @apply directives.
Examples:
# Check a single file (dry-run by default)
tailwhip index.html
# Sort classes in multiple files
tailwhip file1.html file2.html styles.css
# Process all HTML and CSS files in a directory
tailwhip src/templates/
# Actually write changes to files
tailwhip src/ --write
# Preview detailed diff before writing
tailwhip index.html -vv
# Read from stdin and output to stdout
echo '<div class="mt-4 p-2 bg-blue-500"></div>' | tailwhip
╭─ Arguments ──────────────────────────────────────────────────────────────╮
│ paths [PATH] Files or directories to process. │
│ Omit to read from stdin. │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --version -V Show version and exit. │
│ --write -w Write changes to files (default: │
│ dry-run mode). │
│ --quiet -q Suppress output except errors and │
│ warnings. │
│ --verbose -v INTEGER Increase output verbosity (-v: │
│ changes, -vv: diff, -vvv: debug). │
│ [default: 0] │
│ --configuration -c FILE Load custom configuration file │
│ (overrides pyproject.toml settings). │
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────╯Features
Features
Template-Aware
Handles Django, Jinja2, Flask, and other template syntaxes gracefully. Skips files with complex template logic that could break formatting.
Official Sort Order
Sorts classes according to Tailwind's official CSS class order for consistent, predictable formatting across your codebase.
Flexible Integration
Use as a CLI tool, STDIN/STDOUT filter for editors, or import as a Python library. Works with Vim, Emacs, VSCode, and more.
Pre-commit Ready
First-class pre-commit hook support for automated formatting. Never commit unsorted Tailwind classes again.
Highly Configurable
Configure via pyproject.toml or custom TOML files. Customize file patterns, color recognition, and template syntax handling.
Pure Python
No Node.js required. Installs via uv or pip. Requires Python 3.11+.