Tailwind class sorter
Sort utility classes in class/className attributes into Tailwind’s recommended order.
Tailwind class sorter
Paste HTML or JSX and this tool reorders the classes inside every class and className attribute to match Tailwind CSS's recommended order — the same order used by prettier-plugin-tailwindcss: layout and positioning first, then flexbox and grid, spacing, sizing, typography, backgrounds, borders and effects, with responsive and state modifiers (hover:, sm:, dark:) placed after the base utility they modify. A consistent order keeps diffs small and pull requests easy to review, since "flex p-4 text-white" and "text-white p-4 flex" end up identical.
Choose whether to scan the whole pasted document for class and className attributes, or treat the input as a single bare list of classes. Non-Tailwind classes — your own component classes, or names this tool doesn't recognize — stay together at the start or end of each list. Turn on "Remove duplicate classes" to drop exact repeats, and "Warn about classes that cancel each other out" to flag pairs like p-4 and p-2, or block and hidden, that override one another when applied together — the count shows up in the live tally below the output. "Group responsive variants together" clusters every sm:, md: and lg: class at the end instead of interleaving each next to its unprefixed counterpart.
Classes inside a template literal with a JavaScript expression, like className={\`flex \${isActive ? 'bg-red-500' : 'bg-blue-500'} p-4\`}, are left untouched by default since the tool can't know what a variable will render at runtime — turn "Leave dynamic classes untouched" off to sort around them instead. Output as the modified source code, ready to paste back into your editor, or as a plain sorted list, one class per line.
Everything runs locally in your browser — the HTML, JSX or class list you paste is never uploaded anywhere. When you're done, copy the result, download it as a .txt file, or send the output back into the input to run another tool on it.