Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Organize ClassNamesNew to Visual Studio Code? Get it now.
Organize ClassNames

Organize ClassNames

Juan Pablo Pérez

| (0) | Free
Sorts the class names in class="…" and className="…" attributes alphabetically on save. HTML, JSX, TSX, Vue. No configuration needed.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Organize ClassNames

A small VS Code extension that sorts the class names inside class="..." and className="..." attributes alphabetically every time you save an HTML, JavaScript or TypeScript file.

Why: on teams, class lists drift ("p-4 flex mt-2 flex" in one file, "flex mt-2 p-4" in the next). Sorting on save makes diffs smaller and reviews quieter, with no configuration.

What it does

  • Listens to onWillSaveTextDocument for the configured languages (HTML, JS, JSX, TS, TSX, Vue by default).
  • Finds every class="…" / className="…" attribute (double or single quotes) with a regular expression, splits on whitespace, sorts, and writes the result back only when it changed. JSX expressions such as className={clsx(…)} are left alone.
  • No settings, no network, no telemetry.

Limits (by design, for now)

  • Only static string attributes. Template literals and clsx(...) calls are left alone.
  • Alphabetical order, not Tailwind's recommended order. If you want the Tailwind order, use Prettier with prettier-plugin-tailwindcss.

Install

Until it is on the Marketplace: download organize-classnames-0.1.0.vsix from the latest release and run

code --install-extension organize-classnames-0.1.0.vsix

Settings

Setting Default Meaning
organizeClassnames.onSave true Sort automatically on save.
organizeClassnames.languages html, javascript, javascriptreact, typescript, typescriptreact, vue Language ids the extension acts on.

Command palette: Organize ClassNames: Sort class names in this file.

Develop

npm install
npm test             # pure sorter tests (node:test)
npm run compile      # or: npm run watch; then F5 for an Extension Development Host
npx @vscode/vsce package

MIT.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft