prettier-plugin-block-padding weekly downloads statistics
By 1adybug (2 listings) · npm · Prettier plugins
A Prettier plugin that intelligently adds blank lines around code blocks for better visual grouping
prettier-plugin-block-padding has 32 recorded weekly downloads on npm, an increase of 23.1% over the past 30 days, ranking #2877 of 3,247 tracked listings.
About prettier-plugin-block-padding
prettier-plugin-block-padding
Important Notice: This project is entirely generated by Cursor + Claude 4.5 Sonnet Thinking
A Prettier plugin that intelligently inserts blank lines between specific statements to enhance visual grouping of modules and semantic blocks, without altering Prettier's original style and line-breaking decisions. The plugin works on "statement sequences" based on Prettier 3's estree printer, supports all code blocks (including function bodies, if/for/while statement blocks), and does not rewrite formatting and indentation inside expressions.
Key Features
- All Code Blocks Grouping: Inserts an additional blank line before and after specific statements in all code blocks, including file top-level, function bodies, if/for/while statement blocks (i.e., two line breaks separating adjacent statements), enhancing structural separation.
- Smart Multi-line Expression Block Recognition: Automatically identifies and adds blank lines around multi-line expression blocks such as template literals, function expressions, class expressions, JSX elements, etc., improving code readability.
- TypeScript Namespace Support: Applies the same rules to member statements inside
namespace/module(TSModuleBlock), ensuring correct line breaks between braces and first/last lines. - Smart Single-line Detection: Single-line objects, functions, template literals, etc., do not trigger additional blank lines (except object/array literals), avoiding excessive separation.
- Collaboration with Official Parsers: Reuses official
babel,babel-ts, andtypescriptparsers, only overriding the "statement concatenation" during the estree printing stage, leaving other formatting to Prettier.
Behavior Details
In "all code blocks (BlockStatement)", including file top-level (Program), function bodies, if/for/while statement blocks, and TypeScript namespace blocks (TSModuleBlock), the plugin adds an additional blank line between adjacent statements in the following cases:
Unconditional Blank Lines (Even for Single Lines)
- TypeScript Type Declarations:
interface,type,enum(including those wrapped withexport) - Top-level Object/Array Literals:
- Variable declarations initialized with object/array literals
- Expression statements with literals as the main body
Blank Lines Only for Multi-line Cases
-
Multi-line Block Statements: When a statement's printed result is multi-line (e.g.,
if,for,while,do/while,try/catch/finally,switch,function,class,TSModuleDeclaration, etc.), an additional blank line is added between it and adjacent statements. -
Multi-line Expression Blocks (New): When the following expressions span multiple lines, an additional blank line is added between them and adjacent statements:
- Template literals:
`...` - Tagged templates:
styled`...` - Arrow function expressions:
() => {} - Function expressions:
function() {} - Class expressions:
class {} - Multi-line function calls:
fn(...) - Multi-line new expressions:
new Class(...) - JSX elements:
<div>...</div> - JSX fragments:
<>...</>
- Template literals:
Strict Constraints
- No Blank Lines Outside Container Boundaries: Will not add extra blank lines before the file's first line or after the file's last line. However, if the file's first or last line's statement matches the above rules (e.g., object literals, type declarations, multi-line block statements), it will still add blank lines between it and adjacent statements.
- Only Blank Lines Between Statements: Never rewrites formatting within a single statement; specific layouts of expressions, object properties, and function bodies are still determined by Prettier.
- Single-line Does Not Trigger Blank Lines: When a block/expression is finally printed as a single line (without line breaks), it does not trigger additional whitespace.
Summary: The plugin always ensures "at least one line break between adjacent statements", and when rules are matched, an additional line break is added to form a visual blank line.
Examples
Basic Example (Top-level)
Object/array literals, TS type declarations, and multi-line block statements trigger additional whitespace:
const a = 1
const b = {
name: "Tom",
age: 18,
}
if (a) {
const d = 1
}
interface User {
name: string
}
const c = [1, 2, 3]
Function Body Example
The plugin also works inside function bodies, if/for/while, and all code blocks:
function foo() {
const a = 1
const b = {
name: "Tom",
age: 18,
}
if (a) {
const x = 1
const y = {
name: "Jerry",
age: 20,
}
}
const c = [1, 2, 3]
}
Multi-line Expression Block Example
Template literals, function expressions, etc., spanning multiple lines also add blank lines:
const a = 1
const template = `
hello, world!
this is a multiline template
`
const fn = () => {
console.log("test")
}
const b = 2
const styled = css`
color: red;
font-size: 14px;
`
const c = 3
Single-line Does Not Trigger Blank Lines
Single-line template literals, function expressions, etc., do not add blank lines:
const singleTemplate = `hello`
const singleFn = () => console.log("test")
const d = 4
Note: Single-line object/array literals still add blank lines (unconditional rule):
const a = 1
const singleObj = { a: 1 }
const b = 2
Installation
npm i -D prettier-plugin-block-padding
Usage
Add the plugin to your Prettier configuration (recommended to place at the end of the plugins array to ensure the custom estree printer takes effect):…
Description from the npm listing.
- prettier
- prettier-plugin
- formatter
- code-formatting
- blank-lines
- spacing
- block-padding
- typescript
- javascript
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 (592)Similar npm Prettier plugins plugins
All 20 prettier-plugin-block-padding 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-block-padding. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.