Tailwind Class Sorter
Sort Tailwind utility classes into the official recommended order — Layout, Flex/Grid, Spacing, Sizing, Typography, Backgrounds, Borders, Effects, Transitions, Transforms, Interactivity. Responsive (sm:, md:) and state (hover:, focus:) variants stay grouped with their base utility, and arbitrary values like w-[3px] are kept intact. Optionally remove duplicate classes, flag conflicting ones (two text colors, p-2 + p-4), and wrap long lines. Paste a bare class list or a full class="..." / className="..." string — the surrounding attribute is preserved. Everything updates live and is captured in a shareable URL.
About this ToolHow it works, benefits & use casesTap to collapse
A long, randomly-ordered className is hard to scan and harder to diff in review - this sorter reorders Tailwind utility classes into a consistent, recommended sequence and updates live as you type. Paste a bare space-separated list or a full class="..." / className="..." string and it groups the classes by concern: Layout, Positioning, Flexbox/Grid, Spacing, Sizing, Typography, Backgrounds, Borders, Effects, Filters, Transitions, Transforms, Interactivity, and SVG, following the official Tailwind ordering. Responsive and state variants stay grouped: each class is matched on its base utility, so hover:bg-blue-600 sorts next to bg-blue-500, and base classes come before their breakpoint variants (p-4 before sm:p-6 before md:p-8). Arbitrary values like w-[3px] and bg-[#1da1f2] are kept fully intact, and unknown or custom classes fall to the end so nothing is dropped. Optional toggles remove exact duplicate classes, flag conflicting ones (two text colors, p-2 + p-4 in the same scope), and wrap long output to a maximum line length. When the input is a class attribute, the surrounding markup is preserved, so you can paste a whole tag and get it back sorted. Load the example to see it in action, then copy, download, or share the result, or pipe it into another tool.
How to Use
- 1Paste a bare class list, or a full class="..." / className="..." string, or click Load example.
- 2The sorted output updates live in the recommended canonical sequence.
- 3Toggle Remove duplicate classes and Detect conflicting classes as needed.
- 4Optionally set a max line length to wrap long output across several lines.
- 5Copy, download, or share the result, or pipe it straight into another tool.
Key Benefits
- Reorders classes into the official Tailwind concern-based sequence, live
- Keeps responsive and state variants grouped with their base utility
- Base classes sort before their breakpoint variants (p-4 before sm:p-6)
- Preserves arbitrary values like w-[3px] and pushes unknown classes to the end
- Optional duplicate removal with a list of exactly what was removed
- Conflict detection flags two text colors, p-2 + p-4, and similar clashes
- Accepts and re-emits a full class="..." / className="..." attribute
- Optional line wrapping, plus copy, download, share, and pipe-onward
Common Use Cases
- Cleaning up a messy className before committing for tidy diffs
- Spotting accidental conflicts like two background or text colors on one element
- Standardizing class order across a team without adding a build plugin
- Sorting a whole class="..." attribute pasted straight from your markup
- Tidying and de-duplicating classes pasted in from a snippet or generator
Ordered by the official Tailwind concern sequence — updates live
Paste classes to see the sorted result here.
A bare class list, or a full class="…" / className="…" string
Options
Max characters per line (0 = single line)
Variants stay grouped
Each class is matched on its base utility, so hover:bg-blue-600 sorts right next to bg-blue-500. Base classes come before their responsive variants (p-4 before sm:p-6 before md:p-8).
Nothing is lost or renamed
Arbitrary values like w-[3px] and unknown or custom classes are preserved — unrecognized classes simply move to the end. The sorter only reorders; it never rewrites.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related guide
Related tools
- Skeleton Screen GeneratorBuild layout-matched skeleton loaders (card/list/article/table) with shimmer/pulse/wave and a live preview
- Sort LinesSort text lines alphabetically or numerically
- Spacing Scale CalculatorLinear, geometric, Fibonacci or modular spacing scales with a visual ruler preview and utility classes — export CSS, Tailwind v4, SCSS, JSON
- Transition & Easing StudioDrag a cubic-bezier curve, play it on a live demo, and export CSS, @keyframes, Tailwind, Framer, or WAAPI
- CSS FormatterFormat and beautify CSS code
- Design Token GeneratorPerceptual colour ramps + light/dark semantic tokens, live preview, WCAG audit — export CSS, Tailwind v4, W3C DTCG & more
It follows the official Tailwind recommended sequence: Layout, Positioning, Floats, Object fit, Overflow, Z-index, Flexbox/Grid, Spacing, Sizing, Typography, Backgrounds, Borders, Effects, Filters, Tables, Transitions/Animation, Transforms, Interactivity, and SVG. Classes are grouped by concern so related utilities sit together, and the ordering is fully deterministic - sorting an already-sorted list leaves it unchanged.
Each class is matched on its base utility to decide its group, then its variants are re-attached, so hover:bg-blue-600 sorts right next to bg-blue-500 rather than drifting away. Within a group, the unprefixed base class comes first, then responsive variants in breakpoint order (sm:, md:, lg:, xl:, 2xl:), with state variants like hover: and focus: ordered sensibly. This mirrors how you would write mobile-first Tailwind by hand.

