prettier-plugin-tailwindcss

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

Tool
npm
v0.8.1
7,139 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

Python
66%
Other

Morphik

AI Development · Databases · Search

3,717

Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.

View details
64
Repo Health
71
Technical
67
Dependency
Built with
Python 66%
TypeScript 23%
Updated 1 weeks ago
Go
95%
Other

NetBird

Security

30,175

Replace your VPN with a zero-trust WireGuard overlay network that auto-connects devices, enforces SSO and posture checks, and deploys in under 5 minutes.

View details
92
Repo Health
82
Technical
66
Dependency
Built with
Go 95%
Updated 6 days ago
Go
63%
MIT

Obot

AI Agents · Mcp

1,120

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
88
Repo Health
70
Technical
70
Dependency
Built with
Go 63%
Svelte 21%
TypeScript 15%
Updated 1 weeks ago
Ruby
63%
MIT

OnetimeSecret

Security

2,970

Generate self-destructing single-use links to share passwords and sensitive data without leaving traces in inboxes or chat logs.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
Ruby 63%
TypeScript 24%
Updated 6 days ago
TypeScript
99%
Apache 2.0

Onlook

AI Design Tools · Design Tools

26,996

An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.

View details
63
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
Python
64%
Other

Onyx

AI Agents · AI Assistants · Knowledge Management

32,935

Self-hostable AI platform with agentic RAG, 50+ connectors, deep research, code execution, and support for every major LLM provider.

View details
92
Repo Health
83
Technical
68
Dependency
Built with
Python 64%
TypeScript 26%
Updated 6 days ago
TypeScript
99%
Other

Papermark

Digital Signiture · File Storage

9,263

Open-source DocSend alternative with page-by-page analytics, secure data rooms, and custom domains for document sharing.

View details
78
Repo Health
63
Technical
66
Dependency
Built with
TypeScript 99%
Updated 2 months ago
TypeScript
96%
MIT

Payload CMS

Blogging · CMS · Developer Tools

45,458

The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.

View details
92
Repo Health
88
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
96%
Apache 2.0

Pezzo

AI Development · Monitoring

3,278

Open-source LLMOps platform for prompt management, AI observability, intelligent caching, and real-time cost tracking across LLM providers.

View details
59
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 96%
Updated 2 months 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