# prettier-plugin-jinja-template

> Prettier plugin for formatting jinja templates.

Latest version **2.2.0** (published 2026-05-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-plugin-jinja-template
pnpm add prettier-plugin-jinja-template
yarn add prettier-plugin-jinja-template
bun add prettier-plugin-jinja-template
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-05-01 |
| First published | 2022-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 53.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 161 |
| Author | David Odenwald |
| Maintainers | davidodenwald |
| Keywords | prettier, plugin, template, html, jinja, jinja2, flask |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-jinja-template
- Repository: https://github.com/davidodenwald/prettier-plugin-jinja-template
- Homepage: https://github.com/davidodenwald/prettier-plugin-jinja-template#readme
- Issues: https://github.com/davidodenwald/prettier-plugin-jinja-template/issues
- npm.io page: https://npm.io/package/prettier-plugin-jinja-template

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2026-05-01
- 2.1.0 — 2025-04-18
- 2.0.0 — 2024-09-30
- 1.5.0 — 2024-08-25
- 1.4.1 — 2024-06-23
- 1.4.0 — 2024-04-28
- 1.3.3 — 2024-03-03
- 1.3.2 — 2023-12-10
- 1.3.1 — 2023-10-15
- 1.3.0 — 2023-10-15
- 1.2.0 — 2023-10-07
- 1.1.0 — 2023-09-04
- 1.0.0 — 2023-08-12
- 0.5.0 — 2023-05-14
- 0.4.0 — 2023-05-07
- … 9 more at https://npm.io/package/prettier-plugin-jinja-template/versions

## README

# prettier-plugin-jinja-template

Formatter plugin for jinja2 template files.

## Install

```bash
npm install --save-dev prettier prettier-plugin-jinja-template
```

Add the plugin to your `.prettierrc`:
```json
{
  "plugins": ["prettier-plugin-jinja-template"]
}
```

## Use

To format basic .html files, you'll have to override the used parser inside your `.prettierrc`:
```json
{
  "overrides": [
    {
      "files": ["*.html"],
      "options": {
        "parser": "jinja-template"
      }
    }
  ]
}
```

Run it on all HTML files in your project:
```bash
npx prettier --write **/*.html
```

If you don't have a prettier config you can run the plugin with this command:
```bash
npx prettier --plugin=prettier-plugin-jinja-template --parser=jinja-template --write **/*.html
```

### Ignoring Code

Using range ignores is the best way to tell prettier to ignore part of files. Most of the time this is necessary for Jinja tags inside `script` or `style` tags:

```html
<!-- prettier-ignore-start -->
  <script>
    window.someData = {{ data | safe }}
  </script>
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
  <style>
    :root { --accent-color: {{ theme_accent_color }} }
  </style>
<!-- prettier-ignore-end -->
```

Or using Jinja comments:
```jinja
{# prettier-ignore-start #}
  <script>
    window.someData = {{ data | safe }}
  </script>
{# prettier-ignore-end #}

{# prettier-ignore-start #}
  <style>
    :root { --accent-color: {{ theme_accent_color }} }
  </style>
{# prettier-ignore-end #}
```

---
_Source: https://npm.io/package/prettier-plugin-jinja-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
