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

TypeScript
51%
AGPL 3.0

Glean

Bookmarks Archiving · Knowledge Management

872

Self-hosted RSS reader and personal knowledge management tool with MCP server integration for AI assistant connectivity.

View details
73
Repo Health
75
Technical
70
Dependency
Built with
TypeScript 51%
Python 45%
Updated 1 weeks ago
Python
71%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

30,269

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
90
Repo Health
91
Technical
64
Dependency
Built with
Python 71%
TypeScript 18%
Updated 2 weeks ago
Go
87%
MIT

Hatchet

AI Development · Automation · Developer Tools

8,174

A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.

View details
88
Repo Health
83
Technical
67
Dependency
Built with
Go 87%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

9,048

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
67
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

483

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
68
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 1 weeks ago
TypeScript
96%
Other

Infisical

Devops · Security

29,961

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
61%
Unlicense

Invio

Invoicing Finance

1,193

Self-hosted invoicing without the bloat

View details
83
Repo Health
71
Technical
80
Dependency
Built with
TypeScript 61%
Svelte 29%
Updated 1 weeks 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