Prettier plugin for formatting Jinja (Jinja2) template files in HTML and other file types. Current stable version is 2.1.0. It runs as a Prettier plugin and requires Prettier v3+. It parses Jinja syntax mixed with HTML, respects Jinja block structure, and supports range ignores via HTML or Jinja comments. Key differentiators: dedicated Jinja parser (not a generic Liquid/Nunjucks plugin), supports Jinja's specific control flow (for, if, block, etc.), and is actively maintained. It does not format plain HTML or CSS/JS within templates unless paired with a second Prettier plugin like @prettier/plugin-html or prettier-plugin-go-template. TypeScript types are shipped.
npm install prettier-plugin-jinja-templateVerified import paths — ran on the pinned version, not inferred.
Installs Prettier and the plugin, configures .prettierrc with the Jinja parser override, creates a sample template, and formats it.
Upgrade to Node.js 18 or later.
Remove any usage of quoteAttributes from .prettierrc; the option is no longer available.
Chain multiple Prettier plugins or consider using prettier-plugin-go-template which handles HTML+Jinja together.
Use explicit file paths with the plugin: npx prettier --plugin=prettier-plugin-jinja-template --parser=jinja-template --write file.html
Run 'npm install --save-dev prettier prettier-plugin-jinja-template' and ensure the working directory contains the project root.
Add 'parser: "jinja-template"' to .prettierrc overrides for *.html files, or use npx prettier --parser=jinja-template --write template.html
Remove 'quoteAttributes' from .prettierrc or upgrade config to remove it.
Check Jinja syntax for errors, ensure all {% %} blocks are properly closed, and update to latest version.