Tailwind CSS Class Sorter
Sort Tailwind CSS utility classes into a canonical order instantly. Variants (hover:, md:, dark:), arbitrary values, and duplicates are preserved.
Loading tool...
What is Tailwind CSS Class Sorter?
The Tailwind CSS Class Sorter takes any whitespace-separated list of utility classes and reorders it into a deterministic canonical order β layout first, then box model, typography, backgrounds, borders, effects, and interactivity β while preserving variants, arbitrary values, and duplicates.
Key Benefits
- Consistent, review-friendly JSX with no tooling setup
- Fewer meaningless diffs in version control
- Variants grouped predictably next to their base utility
- Optional duplicate removal for cleaner class lists
Common Use Cases
- β’Normalizing hand-written classNames during code review
- β’Cleaning up class lists pasted from AI-generated or legacy code
- β’Enforcing a shared class style on teams without a Prettier plugin
- β’Auditing a class list for duplicates before committing
How to Use the Tailwind CSS Class Sorter
- Paste your classes: Copy a className string from your JSX and paste it into the input box, or click Load sample to try it out.
- Choose duplicate handling: Leave the Remove duplicates checkbox off to keep every class, or tick it to drop repeated tokens automatically.
- Review the sorted output: Classes appear instantly in canonical order: layout, box model, typography, backgrounds, borders, effects, interactivity. Variants stay grouped with their base utility.
- Copy the result: Click Copy and paste the sorted class list back into your code. Unrecognized custom classes sort last, alphabetically.
Key Features
- Canonical class ordering inspired by prettier-plugin-tailwindcss
- Full variant-chain support: dark:md:hover:bg-blue-500 stays intact
- Arbitrary values like w-[13px] and bg-[#1da1f2] preserved exactly
- Optional one-click duplicate removal
- Live stats: class count, duplicates, unrecognized tokens
- 100% client-side β your code never leaves the browser