prettier-plugin-tailwindcss

Prettier plugin that automatically sorts Tailwind CSS classes into a consistent order

Tool
npm
v0.8.1
7,136 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
62 /100 Good
Development Activity 44
Maintenance 52
Community 56
Maturity 56
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 78
Code Quality 80
Innovation 72
Learning Curve 88

prettier-plugin-tailwindcss is the official Prettier plugin from Tailwind Labs that reorders class/className attribute values into Tailwind’s recommended class order every time Prettier formats a file. It removes the bikeshedding over class ordering by consistently sorting classes based on their position in Tailwind’s internal property order, so visually related utilities end up grouped together.

It works across HTML, JSX, Vue, Svelte, Angular, and plain template literals, and automatically detects and reads your project’s tailwind.config.js/tailwind.config.ts (or Tailwind v4 CSS-based config) so custom utilities and variants are sorted correctly alongside built-in ones.

What You Get

  • Automatic sorting of Tailwind classes in class/className attributes on every Prettier format
  • Support for HTML, JSX/TSX, Vue, Svelte, Angular templates, and plain JS/TS template literals
  • Automatic detection of your project’s Tailwind config (JS/TS config or Tailwind v4 CSS-based config) to sort custom utilities correctly
  • A tailwindFunctions/tailwindAttributes option for sorting classes inside custom utility functions (e.g. clsx, cva) or non-standard attributes
  • Compatibility layer supporting both Tailwind CSS v3 and v4 sorting rules
  • An exported sorter entry point for programmatic access to the sorting logic outside of Prettier

Common Use Cases

  • Enforcing a consistent, non-bikeshed Tailwind class order across a team via existing Prettier CI checks
  • Auto-sorting classes generated by class-merging utilities like clsx/cva/classnames via the tailwindFunctions option
  • Keeping class order consistent across HTML, JSX, and Vue templates in a mixed-framework monorepo
  • Migrating a codebase to Tailwind v4 while keeping class ordering behavior compatible with the new engine

Under The Hood

Architecture - The plugin registers as a Prettier astFormat post-processing step: src/index.ts wires up the plugin’s parsers/printers overrides, src/transform.ts walks the AST produced by Prettier’s language parsers to find class-bearing attributes and literals, src/sorting.ts/src/sorter.ts compute the canonical order using Tailwind’s own utility ordering, and src/resolve.ts/src/config.ts locate and load the user’s Tailwind config so custom classes sort correctly; src/versions/ isolates the differences needed to support both Tailwind v3 and v4 config/engine shapes. Tech Stack - Written in TypeScript, distributed as an ESM-only package (type: module, .mjs output) with prettier and tailwindcss as peer dependencies, tested with Vitest (utils.test.ts) and benchmarked with utils.bench.ts, built via a small scripts/ pipeline. Code Quality - The implementation is compact (~3,000 lines across a dozen focused source files) with a dedicated expiring-map.ts cache to avoid re-resolving Tailwind config on every format call, fixture-based tests under tests/fixtures covering each supported template language, and a maintained CHANGELOG; the repo has been actively developed since 2021 with 380+ commits and continuous recent activity. API Design - Installation requires zero configuration beyond adding the plugin to Prettier’s plugins array, and the plugin exposes a small, well-documented options surface (tailwindFunctions, tailwindAttributes, tailwindConfig) plus a standalone sorter export for anyone who wants the sorting logic without running it through Prettier.

Used by 62 apps in this directory

TypeScript
76%
AGPL 3.0

Abby

Developer Tools · Product Management

166

Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.

View details
31
Repo Health
70
Technical
64
Dependency
Built with
TypeScript 76%
MDX 18%
Updated 1 years ago
TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 5 days ago
TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
63%
MIT

ALTCHA

Security

2,781

A self-hosted, privacy-first CAPTCHA alternative that uses memory-hard proof-of-work to stop bots without cookies, tracking, or third-party APIs.

View details
71
Repo Health
79
Technical
75
Dependency
Built with
TypeScript 63%
Svelte 29%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
Rust
67%
MIT

Bun

Developer Tools

96,068

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
64
Dependency
Built with
Rust 67%
C++ 19%
TypeScript 10%
Updated 5 days ago
Java
72%
Other

ByteChef

AI Agents · Automation

1,003

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
67
Dependency
Built with
Java 72%
TypeScript 28%
Updated 5 days ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,049

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
73
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 5 days ago
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,617

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers