consolelog.tools

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 cases

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

  1. 1Paste a bare class list, or a full class="..." / className="..." string, or click Load example.
  2. 2The sorted output updates live in the recommended canonical sequence.
  3. 3Toggle Remove duplicate classes and Detect conflicting classes as needed.
  4. 4Optionally set a max line length to wrap long output across several lines.
  5. 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

Wrap lines

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