prettier-plugin-bootstrap weekly downloads statistics
By pierluigilenoci · npm · Prettier plugins
A Prettier plugin for automatic Bootstrap class sorting
prettier-plugin-bootstrap has 41 recorded weekly downloads on npm, an increase of 70.8% over the past 30 days, ranking #2819 of 3,247 tracked listings.
About prettier-plugin-bootstrap
prettier-plugin-bootstrap
A Prettier plugin that automatically sorts Bootstrap CSS classes following the framework's recommended order.
Works with HTML, JSX/TSX, Vue, Angular, Svelte, and Astro templates.
Why?
- Consistency — Every file in your project uses the same class order, regardless of who wrote it.
- Smaller diffs — Sorted classes eliminate noisy reordering in pull requests.
- Readability — Classes follow Bootstrap's architecture (layout → components → utilities), making it easier to scan what an element does.
- Zero config — Just add the plugin and format. No ESLint rules to configure, no manual sorting.
Installation
npm install -D prettier-plugin-bootstrap
# or
pnpm add -D prettier-plugin-bootstrap
# or
yarn add -D prettier-plugin-bootstrap
Usage
Add the plugin to your Prettier configuration:
{
"plugins": ["prettier-plugin-bootstrap"]
}
That's it! Your Bootstrap classes will now be automatically sorted on format.
HTML
<!-- Before -->
<div class="text-center p-3 container bg-primary text-white mb-4 rounded"></div>
<!-- After -->
<div class="container mb-4 p-3 text-center text-white bg-primary rounded"></div>
JSX / TSX
// Before
<button className="btn-lg mt-2 btn btn-primary d-flex align-items-center">Click</button>
// After
<button className="d-flex align-items-center mt-2 btn btn-primary btn-lg">Click</button>
Vue
<!-- Before -->
<div :class="['text-center', 'container', 'p-3']"></div>
<!-- After -->
<div :class="['container', 'p-3', 'text-center']"></div>
Svelte
<!-- Before -->
<div class="text-white p-2 bg-dark d-flex"></div>
<!-- After -->
<div class="d-flex p-2 text-white bg-dark"></div>
Astro
<!-- Before -->
<div class="rounded text-sm p-4 card shadow"></div>
<!-- After -->
<div class="card p-4 rounded shadow text-sm"></div>
Sorting Order
Classes are sorted following Bootstrap's architecture:
- Layout — containers, grid, columns
- Reboot / Typography — headings, lead, display
- Images — img-fluid, figures
- Tables — table variants
- Forms — form controls, selects, checks
- Buttons — btn variants
- Components — dropdowns, navs, cards, modals, etc. (alphabetical)
- Helpers — clearfix, stacks, visually-hidden
- Utilities — following the order in
scss/_utilities.scss
Within each group, responsive variants (sm, md, lg, xl, xxl) sort after the base class.
Unknown classes are preserved in their original relative order and placed after all known Bootstrap classes.
Options
| Option | Type | Default | Description |
|---|---|---|---|
bootstrapAttributes | string[] | [] | Additional HTML attributes to sort (beyond class and className). Supports regex patterns (e.g. /^data-class/). |
bootstrapFunctions | string[] | [] | Function names whose arguments are class lists (e.g. clsx, classNames) |
bootstrapPreserveWhitespace | boolean | false | Preserve original whitespace between classes instead of normalizing to single spaces |
bootstrapPreserveDuplicates | boolean | true | Keep duplicate class names. Set to false to remove duplicates |
bootstrapVersion | int | 5 | Bootstrap version (4 or 5) |
bootstrapSortTemplateLiterals | boolean | true | Sort static class segments inside JSX template literals that contain expressions. Set to false to skip them |
bootstrapAttributes
Sort classes in custom attributes beyond class / className:
<!-- .prettierrc: { "bootstrapAttributes": ["ngClass"] } -->
<!-- Before -->
<div [ngClass]="'text-center p-3 container'"></div>
<!-- After -->
<div [ngClass]="'container p-3 text-center'"></div>
bootstrapFunctions
Sort class strings passed to utility functions like clsx:
// .prettierrc: { "bootstrapFunctions": ["clsx"] }
// Before
clsx('btn-lg', 'mt-2', 'btn', 'btn-primary')
// After
clsx('mt-2', 'btn', 'btn-primary', 'btn-lg')
bootstrapPreserveWhitespace
Keep original whitespace between classes (default: normalise to single spaces):
<!-- .prettierrc: { "bootstrapPreserveWhitespace": true } -->
<!-- Before -->
<div class="p-3 container mt-2"></div>…
Description from the npm listing.
- prettier
- prettier-plugin
- plugin
- bootstrap
- bootstrap5
- bootstrap-5
- css
- class
- class-sorter
- class-order
- sorting
- sort-classes
- formatter
- html
- jsx
- react
- vue
- svelte
- astro
- angular
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Prettier plugins plugins
All 20 prettier-plugin-bootstrap alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/prettier-plugin-bootstrap. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.