prettier-plugin-nunjucks weekly downloads statistics
By Poliklot (3 listings) · npm · Prettier plugins
Prettier plugin for Nunjucks templates (.njk, .nunjucks, .nunj)
prettier-plugin-nunjucks has 788 recorded weekly downloads on npm, a decrease of 4.8% over the past 30 days, ranking #2146 of 3,247 tracked listings.
About prettier-plugin-nunjucks
prettier-plugin-nunjucks
Prettier plugin for HTML-heavy Nunjucks templates.
It formats .njk / .nunjucks / .nunj files with stable, idempotent output and keeps Nunjucks statement tags, variables, comments, whitespace-control markers, and raw/verbatim blocks in the Nunjucks syntax instead of treating them as Handlebars or generic HTML.
Install
npm install --save-dev prettier prettier-plugin-nunjucks
Quick Start
Recommended config:
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["prettier-plugin-nunjucks"],
overrides: [
{
files: ["*.njk", "*.nunjucks", "*.nunj"],
options: {
parser: "nunjucks",
},
},
],
};
The explicit override makes editor format-on-save deterministic, especially in projects that mix HTML, Nunjucks, Jinja-like templates, and other Prettier plugins.
Configuration Patterns
1. Minimal plugin setup
Use this only after verifying your Prettier/editor resolves .njk files to this plugin.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["prettier-plugin-nunjucks"],
};
2. Explicit Nunjucks override
Use this for shared projects and CI.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["prettier-plugin-nunjucks"],
overrides: [
{
files: ["src/**/*.{njk,nunjucks,nunj}"],
options: {
parser: "nunjucks",
},
},
],
};
3. Projects with Nunjucks in HTML files
If your project stores Nunjucks templates as .html, force the parser for those paths.
{
"plugins": ["prettier-plugin-nunjucks"],
"overrides": [
{
"files": ["views/**/*.html", "templates/**/*.html"],
"options": { "parser": "nunjucks" }
}
]
}
4. Project style options
Normal Prettier options still apply.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["prettier-plugin-nunjucks"],
overrides: [
{
files: ["**/*.{njk,nunjucks,nunj}"],
options: {
parser: "nunjucks",
printWidth: 100,
tabWidth: 2,
singleQuote: true,
htmlWhitespaceSensitivity: "ignore",
},
},
],
};
5. Local plugin path during dogfooding
Useful before publishing a new npm version.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["../prettier-plugin-nunjucks/dist/plugin.js"],
overrides: [
{
files: ["**/*.{njk,nunjucks,nunj}"],
options: {
parser: "nunjucks",
},
},
],
};
Text wrapping
Normal HTML text wraps at word boundaries to respect printWidth, including the
available width after indentation. Nunjucks variables stay intact, and words or
punctuation glued to them stay glued. proseWrap does not control HTML text
wrapping, just as with Prettier's HTML printer.
printWidth is a target, not a hard limit: unbreakable words, template expressions,
and whitespace-sensitive content such as pre, textarea, and raw/verbatim blocks
may remain longer than it.
Text and inline variables wrap as one text flow inside HTML block elements such
as p and div, Nunjucks block bodies, and the template root. Configured
inlineTags participate in the same flow. Existing line breaks in ordinary text
do not force variables onto separate lines or disable wrapping. Actual inline
HTML elements such as a and span retain their significant tag boundaries.
classAttributeLayout
Control whether class attribute values may use multiple physical lines. The default auto mode preserves the existing formatting rules. Use single-line to keep static and conditional class values on one line; the surrounding HTML tag may still wrap.
| Default | CLI Override | API Override |
|---|---|---|
"auto" | --class-attribute-layout <auto|single-line> | classAttributeLayout: "auto" | "single-line" |
{
"plugins": ["prettier-plugin-nunjucks"],
"classAttributeLayout": "single-line"
}
Custom extension tags
Nunjucks extensions can define project-specific tags. Unknown single statement tags are preserved by default; tags that behave like blocks or branches can be configured explicitly.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["prettier-plugin-nunjucks"],
overrides: [
{
files: ["**/*.{njk,nunjucks,nunj}"],
options: {
parser: "nunjucks",
blockTags: ["remote"],
forkTags: ["error"],
},
},
],
};
Input:
{% remote "/stuff" %}
This content will be replaced with the content from /stuff
{% error %}
There was an error fetching /stuff
{% endremote %}
Output:
{% remote "/stuff" %}
This content will be replaced with the content from /stuff
{% error %}
There was an error fetching /stuff
{% endremote %}
CLI
Published package:
npx prettier --write "src/**/*.{njk,nunjucks,nunj}" --plugin prettier-plugin-nunjucks --parser nunjucks
Local plugin build:
npx prettier --write "src/**/*.{njk,nunjucks,nunj}" --plugin ../prettier-plugin-nunjucks/dist/plugin.js --parser nunjucks
API
const prettier = require("prettier");
const plugin = require("prettier-plugin-nunjucks");
async function run(source) {
return prettier.format(source, {
filepath: "template.njk",
parser: "nunjucks",
plugins: [plugin],
});
}
What The Plugin Handles Today…
Description from the npm listing.
- prettier
- prettier-plugin
- nunjucks
- njk
- jinja
- html
- formatter
- eleventy
- 11ty
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-nunjucks 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-nunjucks. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.