djLint Logo

🙏 Passed 100k downloads! Thank you! 🙏

The missing formatter and linter for HTML templates.

tweet Discord Chat

Codecov Status Codacy Status Downloads npm Pypi Download

How to useКак пользоватьсяUtilisation

What lang are you using?

DjangoJinjaNunjucksTwigHandlebarsMustacheGoLangAngular

demo

## 🤔 For What? Once upon a time all the other programming languages had a formatter and linter. Css, javascript, python, the c suite, typescript, ruby, php, go, swift, and you know the others. The cool kids on the block. HTML templates were left out there on their own, in the cold, unformatted and unlinted :( The dirty corner in your repository. Something had to change. **djLint is a community build project to and add consistency to html templates.** ## ✨ How? Grab it with `pip` ```bash pip install djlint ``` *Or with the npm experimental install - Note, this requires python and pip to be on your system path.* ```bash npm i djlint ``` Lint your project ```bash djlint . --extension=html.j2 --lint ``` Check your format ```bash djlint . --extension=html.j2 --check ``` Fix my format! ```bash djlint . --extension=html.j2 --reformat ``` ## 💙 Like it? Add a badge to your projects ```readme.md```: ```md [![Code style: djlint](https://img.shields.io/badge/html%20style-djlint-blue.svg)](https://www.djlint.com) ``` Add a badge to your ```readme.rst```: ```rst .. image:: https://img.shields.io/badge/html%20style-djlint-blue.svg :target: https://www.djlint.com ``` Looks like this: [![djLint](https://img.shields.io/badge/html%20style-djLint-blue.svg)](https://github.com/Riverside-Healthcare/djlint) ## 🛠️ 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 [source code](https://github.com/Riverside-Healthcare/djLint/blob/master/src/djlint/rules.yaml) *Are you a regex pro?* Benchmark and submit a pr with improved regex for the [linter rules](https://github.com/Riverside-Healthcare/djLint/blob/master/src/djlint/rules.yaml) **⚠️ Help Needed! ⚠️** *Good with python?* djLint was an experimental project and is catching on with other devs. Help out with a rewrite of the formatter to improve speed and html style for edge cases. Contribute on the [2.0 branch](https://github.com/Riverside-Healthcare/djLint/tree/block_indent) ## 🏃 Other Tools Of Note * [DjHTML](https://github.com/rtts/djhtml) A pure-Python Django/Jinja template indenter without dependencies. * [HTMLHint](https://htmlhint.com) Static code analysis tool you need for your HTML * [curlylint](https://www.curlylint.org) Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid