Registry / devops / prettier-plugin-sort-markdown-table

prettier-plugin-sort-markdown-table

JSON →
library2.0.0jsnpmunverified

Prettier plugin that sorts the rows of markdown tables alphabetically by the first column. Current stable version is 2.0.0, released May 2025, with a slow release cadence. Requires Prettier 3.x. Table sorting is opt-in: only tables preceded by a `<!-- prettier-sort-markdown-table -->` comment are sorted. Key differentiator: minimal configuration — just drop in and annotate — unlike other markdown formatters that require manual sorting.

npm install prettier-plugin-sort-markdown-table
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-SO
P
prettier-plugin-sort-markdown-table
devopsjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
plugins: [require('prettier-plugin-sort-markdown-table')]
import prettierPluginSortMarkdownTable from 'prettier-plugin-sort-markdown-table'
Prettier plugins are typically loaded via require in .prettierrc.js or prettier.config.js; ESM import is not recommended for plugin registration.
default export
export default { plugins: ['prettier-plugin-sort-markdown-table'] }
import { default } from 'prettier-plugin-sort-markdown-table'
The package does not export any symbols for programmatic usage; it only registers as a Prettier plugin.
CLI usage
npx prettier --plugin=prettier-plugin-sort-markdown-table --write README.md
prettier --plugin='prettier-plugin-sort-markdown-table' README.md
The plugin must be specified with --plugin flag when running prettier CLI if not auto-loaded.

Installs the plugin, configures Prettier to load it automatically, then formats a markdown table with the opt-in comment.

npm i -D prettier prettier-plugin-sort-markdown-table cat > .prettierrc.js << 'EOF' module.exports = { plugins: ['prettier-plugin-sort-markdown-table'], }; EOF cat > README.md << 'EOF' <!-- prettier-sort-markdown-table --> | name | email | | ---- | ----- | | zhang | zhang@a.com | | wang | wang@a.com | | alice | alice@example.com | EOF npx prettier --write README.md # Output README.md rows sorted by first column alphabetically: alice, wang, zhang
Debug
Known issues
breakingv2.0.0 drops support for Prettier 2; requires Prettier 3.x
fix
Upgrade Prettier to version 3.x
affects: >=2.0.0
gotchaTable sorting only works when preceded by the annotation comment `<!-- prettier-sort-markdown-table -->`. Without it, no sorting occurs.
fix
Add `<!-- prettier-sort-markdown-table -->` on the line immediately above the table.
affects: >=1.0.0
gotchaThe plugin may conflict with other prettier plugins that also process markdown (e.g., prettier-plugin-md-nocjsp) leading to unexpected order of operations.
fix
Ensure plugins are listed in the correct order or test formatting with both plugins enabled.
affects: >=1.0.0
deprecatedv1.x is deprecated and may not work with newer Prettier versions; upgrade to v2 for compatibility.
fix
Upgrade to v2.0.0 and Prettier 3.x
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-sort-markdown-table'
Plugin not installed or not in node_modules.
fix
Run `npm i -D prettier-plugin-sort-markdown-table`
Error: Invalid plugin: prettier-plugin-sort-markdown-table
Prettier version is too old (pre v3) or plugin is not compatible.
fix
Upgrade Prettier to 3.x and use plugin v2.0.0 or later
Error: [pretty-quick] No files matching the pattern found in the working tree.
Running pretty-quick without specifying markdown files, or using wrong glob pattern.
fix
Use `pretty-quick --pattern '**/*.md'`
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
prettierrequiredpeer dependency — plugin requires Prettier 3.x
Agent activity
9 hits · last 30 days
node
8
Resources
prettier-plugin-sort-markdown-table — npm install prettier-plugin-sort-markdown-table · libregistry