Metadata-Version: 2.5
Name: djlint
Version: 1.52.2
Summary: HTML template linter and formatter (Django, Jinja, Twig, Nunjucks, Handlebars, Mustache, Liquid, Go templates, Angular, Tera, Askama, Mako)
Project-URL: changelog, https://github.com/djlint/djLint/blob/master/CHANGELOG.md
Project-URL: documentation, https://djlint.com
Project-URL: issues, https://github.com/djlint/djLint/issues
Project-URL: repository, https://github.com/djlint/djLint
Author: Christopher Pickering
Maintainer: Christopher Pickering
Maintainer-email: monosans <hsyqixco@protonmail.com>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
License-File: LICENSE-THIRD-PARTY
Keywords: angular,askama,django,formatter,go templates,handlebars,helm,html,hugo,jinja,jinja2,language server,linter,liquid,lsp,mako,mustache,nunjucks,templates,tera,twig
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: 3.16
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: click>=8.2.0
Requires-Dist: cssbeautifier>=1.13.0
Requires-Dist: jsbeautifier>=1.13.0
Requires-Dist: json5>=0.10.0
Requires-Dist: pathspec>=0.9.0
Requires-Dist: pyyaml>=5.1
Requires-Dist: regex>=2020.10.22
Requires-Dist: typing-extensions>=4.4.0; python_version < '3.13'
Description-Content-Type: text/markdown

<h1 align="center">
  <br>
  <a href="https://djlint.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://djlint.com/static/img/logo-wide-dark.svg"><img src="https://djlint.com/static/img/logo-wide-light.svg" alt="djLint Logo" width="300"></picture></a>
  <br>
</h1>
<h4 align="center">The missing formatter and linter for HTML templates.</h4>

<p align="center">
   <a href="https://pypi.org/project/djlint/">
     <img src="https://pepy.tech/badge/djlint" alt="Downloads">
   </a>
   <a href="https://discord.gg/taghAqebzU">
     <img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdiscord.com%2Fapi%2Fv10%2Finvites%2FtaghAqebzU%3Fwith_counts%3Dtrue&query=%24.approximate_presence_count&label=discord&suffix=%20online&logo=discord&logoColor=white&color=5865F2" alt="Discord">
   </a>
</p>

<h4 align="center">How to use: <a href="https://djlint.com/">English</a> • <a href="https://djlint.com/zh/">简体中文</a> • <a href="https://djlint.com/ja/">日本語</a> • <a href="https://djlint.com/es/">Español</a> • <a href="https://djlint.com/pt-br/">Português (Brasil)</a> • <a href="https://djlint.com/ru/">Русский</a> • <a href="https://djlint.com/ko/">한국어</a> • <a href="https://djlint.com/fr/">Français</a> • <a href="https://djlint.com/de/">Deutsch</a> • <a href="https://djlint.com/zh-tw/">繁體中文</a> • <a href="https://djlint.com/it/">Italiano</a> • <a href="https://djlint.com/pl/">Polski</a> • <a href="https://djlint.com/cs/">Čeština</a> • <a href="https://djlint.com/tr/">Türkçe</a></h4>
<h4 align="center">Template languages</h4>

<p align="center">
   <a href="https://djlint.com/docs/languages/django/">Django</a> • <a href="https://djlint.com/docs/languages/jinja/">Jinja</a> • <a href="https://djlint.com/docs/languages/twig/">Twig</a> • <a href="https://djlint.com/docs/languages/nunjucks/">Nunjucks</a> • <a href="https://djlint.com/docs/languages/handlebars/">Handlebars</a> • <a href="https://djlint.com/docs/languages/mustache/">Mustache</a> • <a href="https://djlint.com/docs/languages/liquid/">Liquid</a> • <a href="https://djlint.com/docs/languages/golang/">Go templates</a> • <a href="https://djlint.com/docs/languages/angular/">Angular</a> • <a href="https://djlint.com/docs/languages/tera/">Tera</a> • <a href="https://djlint.com/docs/languages/askama/">Askama</a> • <a href="https://djlint.com/docs/languages/mako/">Mako</a>
</p>

## 🤔 For What?

Generic HTML tools can't parse `{% %}` and `{{ }}`, and template engines don't care what the markup around them looks like. So indentation drifts, tags go unclosed and spacing goes wherever, and none of it gets caught in review.

djLint reads HTML _and_ the template syntax inside it, with profiles for Django, Jinja, Twig, Nunjucks, Handlebars, Liquid, Go templates and more. It runs from the command line, as a pre-commit hook and as a language server in your editor.

Take a template only its author could love:

```django
{% block content %}
<SECTION class="posts">


<h2>Latest posts</h2>
{%if posts%}
<ul>
{% for post in posts %}
<li>
<a href="{% url 'post' post.slug %}" class="post-link {%if post.featured%}is-featured{%endif%}" data-analytics-id="post-{{post.id}}" aria-label="Read {{post.title}}">{{post.title|title}}</a>
</li>
{% endfor %}
</ul>
{%else%}
<p>No posts yet.</p>
{%endif%}
</SECTION>
{% endblock %}
```

One `djlint --reformat --single-attribute-per-line` later:

```django
{% block content %}
    <section class="posts">
        <h2>Latest posts</h2>
        {% if posts %}
            <ul>
                {% for post in posts %}
                    <li>
                        <a
                            href="{% url 'post' post.slug %}"
                            class="post-link {% if post.featured %}is-featured{% endif %}"
                            data-analytics-id="post-{{ post.id }}"
                            aria-label="Read {{ post.title }}"
                        >{{ post.title|title }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% else %}
            <p>No posts yet.</p>
        {% endif %}
    </section>
{% endblock %}
```

One command rebuilt the indentation, fixed the tag case, split the long tag into one attribute per line, normalized the template tags and collapsed stray blank lines.

The linter catches what formatting can't fix: orphan tags, missing `alt` attributes, hard-coded URLs and dozens of other checks.

You can [try it on your own templates in the online playground](https://djlint.com/demo/).

## ✨ How?

Add it to your project as a development dependency with [uv](https://docs.astral.sh/uv/), or install it with pip:

```bash
uv add --dev djlint
# or
pip install djlint
```

With uv, put `uv run` in front of the commands below, as in `uv run djlint . --lint`. The [installation guide](https://djlint.com/docs/getting-started/#installation) also covers installing it as a standalone tool, and with pipx, Homebrew or npm.

Lint your project:

```bash
djlint . --lint
```

See what formatting would change:

```bash
djlint . --check --single-attribute-per-line
```

Format the files in place:

```bash
djlint . --reformat --single-attribute-per-line
```

Set a `--profile` for the rules and formatting of your template language:

```bash
djlint . --reformat --single-attribute-per-line --profile=django
```

Or run it with [pre-commit](https://djlint.com/docs/integrations/#pre-commit), formatting first and then linting:

```yaml
repos:
  - repo: https://github.com/djlint/djLint
    rev: v1.52.2 # use the latest version instead
    hooks:
      - id: djlint-reformat
      - id: djlint
```

## 🧩 Editors

- **VS Code**: install the [djLint extension](https://marketplace.visualstudio.com/items?itemName=monosans.djlint) (also on [Open VSX](https://open-vsx.org/extension/monosans/djlint)).
- **Zed**: install the [djLint extension](https://github.com/djlint/djlint-zed) as a dev extension until it's in Zed's registry. See [how](https://djlint.com/docs/integrations/#zed).
- **Neovim, JetBrains IDEs, Sublime Text, Helix and Emacs**: run the language server, `djlint --lsp`. See the [setup for each](https://djlint.com/docs/integrations/).
- **CI**: [GitHub Actions](https://djlint.com/docs/integrations/#github-actions) and [MegaLinter](https://djlint.com/docs/integrations/#megalinter).

## 💙 Like it?

Add a badge to your project's `readme.md`:

```md
[![html style: djLint](https://img.shields.io/badge/html%20style-djLint-blue.svg)](https://djlint.com)
```

Add a badge to your `readme.rst`:

```rst
.. image:: https://img.shields.io/badge/html%20style-djLint-blue.svg
   :target: https://djlint.com
```

Looks like this:

[![html style: djLint](https://img.shields.io/badge/html%20style-djLint-blue.svg)](https://djlint.com)

## 🛠️ Can I help?

Yes!

_Would you like to add a rule to the linter?_ Take a look at the [linter docs](https://djlint.com/docs/linter/) and the [rule definitions](https://github.com/djlint/djLint/blob/master/src/djlint/rules.yaml).

Local setup takes two commands:

```bash
# install uv first: https://docs.astral.sh/uv/getting-started/installation/
uv sync

# run the test suite
uv run pytest
```

## 🏃 Other tools of note

- [djade](https://github.com/adamchainz/djade) A fast Django template formatter that formats template syntax whilst leaving HTML as-is, and applies fixes for older Django versions.
- [djangofmt](https://github.com/UnknownPlatypus/djangofmt) A fast, HTML-aware Django/Jinja template formatter written in Rust that formats HTML and template syntax together.
- [DjHTML](https://github.com/rtts/djhtml) A pure-Python Django/Jinja template indenter without dependencies.
- [prettier-plugin-jinja-template](https://github.com/davidodenwald/prettier-plugin-jinja-template) Prettier plugin for formatting Jinja and Django templates.
- [prettier-plugin-twig](https://github.com/zackad/prettier-plugin-twig) Prettier plugin for formatting Twig templates.
- [Twig-CS-Fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) A PHP tool that lints and automatically fixes Twig coding-standard issues.
- [ludtwig](https://github.com/MalteJanz/ludtwig) A fast Rust linter and formatter for Twig templates that also validates HTML structure and supports auto-fix.
