All Tools › Web & Developer

Tailwind CSS Class Sorter

Automatically organize and reorder Tailwind utility classes by category — layout, spacing, typography, colors, and more.

Input Classes

Sorted Output 0 classes

Your organized classes will appear here after sorting.

How It Works

The sorter parses each class token using regex-based prefix matching and assigns it to one of Tailwind's official ordering categories — layout, flexbox/grid, spacing, sizing, typography, backgrounds, borders, effects, transitions, transforms, interactivity, and accessibility. Each class receives a numeric weight based on its category rank, then classes are stable-sorted by weight. Optional deduplication uses a Set to keep only the first occurrence. Category tags are generated from the matched prefix so you can visually scan the structure of your utility stack.

Frequently Asked Questions

Why should I sort Tailwind classes?
Sorting makes long class strings scannable — layout and spacing come first, then typography and colors, then effects and states. It reduces merge conflicts in teams and matches the recommended order from Tailwind's official style guide.
Does this tool support variants like hover:, md:, and dark:?
Yes. Variants are stripped before categorization so a class like md:p-6 sorts correctly as padding, and hover:bg-blue-600 sorts as a background. The variant prefix is preserved in the output.
Is the sorting order the same as Prettier Plugin Tailwindcss?
Very close. This sorter follows Tailwind's official documented category order (layout → spacing → typography → backgrounds → effects → states), which matches the default preset used by the Prettier plugin.

Related Tools

Copied!
Free tools by TUNA — energy supply from vetted manufacturers