Configuration
Configuration goes in your project’s pyproject.toml, a djlint.toml or .djlint.toml, or a .djlintrc. Command line options override the config file, but a flag can only turn an option on, so it can’t turn off a switch the config file sets. The project’s settings override a global config file given with --configuration, unless --prefer-configuration is set.
djLint looks for these files upward from the first path it checks (for -, from the folder of --stdin-filename, or from the current directory without it). It stops at the first folder that holds a djlint.toml, a .djlint.toml, a .djlintrc, a .djlint_rules.yaml or a pyproject.toml with [tool.djlint], and never goes past the root of a repository (a folder with a .git folder or file, or a .hg folder). A pyproject.toml without djLint settings doesn’t stop it, so a package in a monorepo with its own pyproject.toml gets the settings of the repository. djLint reads only the folder it stops at: [tool.djlint] in its pyproject.toml if that table sets anything, otherwise its djlint.toml or .djlint.toml, otherwise its .djlintrc, and warns about the ones there that it doesn’t read.
Where neither the command line nor the configuration sets indent or max_line_length, djLint takes indent_size or max_line_length from .editorconfig files, as editors do: each file gets them by its own path, the nearest .editorconfig wins and the ones above it fill in, up to one with root = true or the project root.
The format for pyproject.toml is toml.
[tool.djlint]profile = "django"ignore = ["H014", "H015"]The format for djlint.toml and .djlint.toml is toml.
profile = "django"ignore = ["H014", "H015"]The format for .djlintrc is json.
{ "profile": "django", "ignore": ["H014", "H015"] }Options that take several values, such as ignore, take a list. A comma-separated string such as "H014,H015" works too, and is what djLint before 1.41 needs.
From version 1.51, djLint warns about a setting or a rule code it doesn’t know, and names the closest one it does.
Options
Section titled “Options”Nothing found. Try another search.
allow_empty_input
Default: false
Exit with 0 instead of 2 when the given paths match no files at all. Files that were found and then skipped by exclude, extend_exclude, use_gitignore or require_pragma already exit with 0.
allow_empty_input=trueallow_empty_input=true"allow_empty_input": true--allow-empty-inputblank_line_after_tag
Default: none
Template tags to follow with a blank line, such as load and extends. A group of them in a row gets one after the last, and none is added at the end of a block.
blank_line_after_tag=["load", "extends", "include"]blank_line_after_tag=["load", "extends", "include"]"blank_line_after_tag": ["load", "extends", "include"]--blank-line-after-tag "load,extends,include"blank_line_before_tag
Default: none
Template tags to precede with a blank line, such as load and extends. A group of them in a row gets one before the first, and none is added at the start of a file or block.
blank_line_before_tag=["load", "extends", "include"]blank_line_before_tag=["load", "extends", "include"]"blank_line_before_tag": ["load", "extends", "include"]--blank-line-before-tag "load,extends,include"close_void_tags
Default: false
Close known void tags with a slash, so <img> becomes <img />. H018, which asks for the opposite, is not reported under it.
close_void_tags=trueclose_void_tags=true"close_void_tags": true--close-void-tagsconfiguration
A global config file, a pyproject.toml, djlint.toml or .djlintrc, such as one in your home folder. The project’s own config file wins where both set an option, unless prefer_configuration is on.
--configuration ~/.djlintrccustom_blocks
Default: none
Names of custom template blocks to indent, such as toc for {% toc %}...{% endtoc %}.
custom_blocks=["toc", "example"]custom_blocks=["toc", "example"]"custom_blocks": ["toc", "example"]--custom-blocks "toc,example"custom_html
Default: none
Names of custom HTML tags to indent, such as mjml or simple-greeting. A name can be a regex, as in mj-\w+.
custom_html=["mjml", "simple-greeting", 'mj-\w+']custom_html=["mjml", "simple-greeting", 'mj-\w+']"custom_html": ["mjml", "simple-greeting", "mj-\\w+"]--custom-html "mjml,simple-greeting,mj-\w+"exclude
Default: "__pypackages__,
Paths to skip, in place of the default list. Each entry is a regular expression matched against whole folder or file names in the path relative to the project root or to the folder being checked, such as vendor or templates/legacy, so *.min.html is written .*\.min\.html.
exclude=[".venv", "venv", "build"]exclude=[".venv", "venv", "build"]"exclude": [".venv", "venv", "build"]--exclude ".venv,venv,build"extend_exclude
Default: none
Paths to skip on top of exclude, or of the default list when exclude isn’t set, as regular expressions like those of exclude.
extend_exclude=[".custom"]extend_exclude=[".custom"]"extend_exclude": [".custom"]--extend-exclude ".custom"extension
Default: "html"
Extension of the files to look for in folders. It takes one extension; a file given by name is checked whatever its extension.
extension="html.dj"extension="html.dj""extension": "html.dj"--extension "html.dj"# or-e "html.dj"files
Default: none
Paths to check instead of the ones on the command line, which must then be -, as for stdin. With --stdin-filename, - means stdin regardless.
[tool.djlint]files=["index.html"]files=["index.html"]"files": [ "index.html"]index.htmlformat_attribute_js_json
Default: false
Also format JavaScript and JSON in attributes such as onclick and x-data, the ones format_attribute_js_json_pattern names. An object with fewer properties than format_attribute_js_json_min_props stays on one line.
format_attribute_js_json=trueformat_attribute_js_json=true"format_attribute_js_json": true--format-attribute-js-jsonformat_attribute_js_json_min_props
Default: 2
Format an object only when it has at least this many properties. One with fewer stays on one line.
format_attribute_js_json_min_props=3format_attribute_js_json_min_props=3"format_attribute_js_json_min_props": 3--format-attribute-js-json-min-props 3format_attribute_js_json_pattern
Default: "^(?:on[a-z]+|
Regex for the names of the attributes to format as JavaScript or JSON. The default takes on* event handlers and the bindings of Alpine, Vue, Angular and Aurelia.
format_attribute_js_json_pattern="^(on[a-z]+|data-[a-z-]+|x-[a-z-]+)$"format_attribute_js_json_pattern="^(on[a-z]+|data-[a-z-]+|x-[a-z-]+)$""format_attribute_js_json_pattern": "^(on[a-z]+|data-[a-z-]+|x-[a-z-]+)$"--format-attribute-js-json-pattern "^(on[a-z]+|data-[a-z-]+|x-[a-z-]+)$"format_attribute_template_tags
Default: false
Format template syntax inside tag attributes.
format_attribute_template_tags=trueformat_attribute_template_tags=true"format_attribute_template_tags": true--format-attribute-template-tagsformat_css
Default: false
Also format the contents of <style> tags, with css-beautify. Template syntax inside them is not fully supported.
indent_size in the css table, or --indent-css on the command line, sets the indent inside <style> tags, 4 by default. The table takes the other css-beautify options too.
[tool.djlint]format_css=true
[tool.djlint.css]indent_size=5format_css=true
[css]indent_size=5"format_css": true,"css": { "indent_size": 5 }--format-css --indent-css 5format_js
Default: false
Also format JavaScript and JSON in <script> tags, with js-beautify. A script whose type is neither JavaScript nor JSON, such as a client-side template in text/template, is left as written. Template syntax inside them is not fully supported.
indent_size in the js table, or --indent-js on the command line, sets the indent inside <script> tags, 4 by default. The table takes the other js-beautify options too.
[tool.djlint]format_js=true
[tool.djlint.js]indent_size=5format_js=true
[js]indent_size=5"format_js": true,"js": { "indent_size": 5 }--format-js --indent-js 5github_output
Default: none
Print the results as GitHub Actions annotations. It’s on by default inside GitHub Actions, and --no-github-output turns it off. See GitHub Actions.
--github-outputignore
Default: none
Linter codes to skip.
ignore=["H014", "H015"]ignore=["H014", "H015"]"ignore": ["H014", "H015"]--ignore "H014,H015"ignore_blocks
Default: none
Template blocks that do not indent their contents. Their children are treated as siblings of the block and indented accordingly.
ignore_blocks=["raw", "example"]ignore_blocks=["raw", "example"]"ignore_blocks": ["raw", "example"]--ignore-blocks "raw,example"ignore_case
Default: false
Do not fix the case of known HTML tags. H009 and H010 are not reported under it.
[tool.djlint]ignore_case=trueignore_case=true"ignore_case": true--ignore-caseinclude
Default: none
Linter codes to turn on that are off by default or that the profile leaves out.
include=["H014", "H015"]include=["H014", "H015"]"include": ["H014", "H015"]--include "H014,H015"indent
Default: 4
Spaces per indent level. When it isn’t set, djLint takes the indent_size that .editorconfig gives the file, if any.
indent=3indent=3"indent": 3--indent 3keep_br_inline
Default: false
Keep <br> on the line of the text it breaks, rather than giving it a line of its own. <hr>, which renders as a rule below the preceding content, is unaffected.
keep_br_inline=truekeep_br_inline=true"keep_br_inline": true--keep-br-inlineline_break_after_multiline_tag
Default: false
When a tag’s attributes are spread over lines, start its content on a new line.
line_break_after_multiline_tag=trueline_break_after_multiline_tag=true"line_break_after_multiline_tag": true--line-break-after-multiline-taglinter_output_format
Default: "{code} {line} {message} {match}"
The layout of each lint message, from {filename}, {line}, {end}, {code}, {message} and {match}. Without {filename}, the output is grouped by file and each group gets a header.
linter_output_format="{filename}:{line}: {code} {message} {match}"linter_output_format="{filename}:{line}: {code} {message} {match}""linter_output_format": "{filename}:{line}: {code} {message} {match}"--linter-output-format "{filename}:{line}: {code} {message} {match}"max_attribute_length
Default: 70
The formatter spreads a tag’s attributes over lines once they are longer than this.
max_attribute_length=10max_attribute_length=10"max_attribute_length": 10--max-attribute-length 10max_blank_lines
Default: 0
Keep at most this many blank lines in a row, so 0 removes them. It has no effect with preserve_blank_lines.
max_blank_lines=5max_blank_lines=5"max_blank_lines": 5--max-blank-lines 5max_line_length
Default: 120
The formatter joins some HTML and template tags onto one line only when the line fits within this length. When it isn’t set, djLint takes the max_line_length that .editorconfig gives the file, if any.
max_line_length=100max_line_length=100"max_line_length": 100--max-line-length 100name_endblocks
Default: false
Write the block’s name into the {% endblock %} that closes it, where the block is written across lines. This is what T003 asks for.
name_endblocks=truename_endblocks=true"name_endblocks": true--name-endblocksno_entity_formatting
Default: false
Do not rewrite an entity reference as the character it names, so © is left as written rather than becoming ©. The entities that carry syntax, and the invisible ones, are never rewritten either way. H023 still reports an entity under it; add H023 to ignore to keep entities.
no_entity_formatting=trueno_entity_formatting=true"no_entity_formatting": true--no-entity-formattingno_function_formatting
Default: false
Do not format the arguments of function calls inside {{ }}.
no_function_formatting=trueno_function_formatting=true"no_function_formatting": true--no-function-formattingno_indent_inner_html
Default: false
Do not indent <head> and <body> inside <html>, which is how the built-in VS Code HTML formatter lays a document out.
no_indent_inner_html=trueno_indent_inner_html=true"no_indent_inner_html": true--no-indent-inner-htmlno_line_after_yaml
Default: false
Do not add a blank line after YAML front matter.
no_line_after_yaml=trueno_line_after_yaml=true"no_line_after_yaml": true--no-line-after-yamlno_set_formatting
Default: false
Do not format the contents of {% set %} tags.
no_set_formatting=trueno_set_formatting=true"no_set_formatting": true--no-set-formattingper_file_ignores
Default: none
Linter codes to skip in the files whose path matches a regex. In a config file the key is per-file-ignores, with hyphens.
[tool.djlint.per-file-ignores]"file.html"= "H026,H025""file_two.html"="H001"[per-file-ignores]"file.html"= "H026,H025""file_two.html"="H001""per-file-ignores": { "file.html": "H026,H025", "file_two.html":"H001" }--per-file-ignores "file.html" "H026,H025" --per-file-ignores "file_two.html" "H001"prefer_configuration
Default: false
Let the file named by --configuration override the project’s own config file, which wins by default where both set the same option. Command line only, since it decides how the config files themselves are read.
--prefer-configurationpreserve_blank_lines
Default: false
Keep blank lines where possible. Useful for templates other than HTML, where blank lines are intentional.
preserve_blank_lines=truepreserve_blank_lines=true"preserve_blank_lines": true--preserve-blank-linespreserve_class_newlines
Default: false
Keep the line breaks in class attributes written across lines.
preserve_class_newlines=truepreserve_class_newlines=true"preserve_class_newlines": true--preserve-class-newlinespreserve_leading_space
Default: false
Keep the leading spaces of text lines where possible. Useful for templates other than HTML, where the indent of text is intentional.
preserve_leading_space=truepreserve_leading_space=true"preserve_leading_space": true--preserve-leading-spaceprofile
Default: none
The template language. It decides which linter rules run and how the template syntax is formatted: in handlebars, for example, there are no spaces inside {{#if}} tags.
Without a profile, djLint formats the template syntax of every language, as all does, and lints with the rules of html.
Options:
- html
- django
- jinja
- nunjucks (for nunjucks and twig)
- handlebars (for handlebars and mustache)
- liquid (shopify, jekyll, eleventy)
- golang (go templates; hugo, helm)
- angular
- tera (also for zola; use jinja for minijinja)
- askama (jinja-style templates in rust; rust expressions are never reformatted)
- mako (control lines and
##comments are kept as written) - all (every template language at once)
profile="django"profile="django""profile": "django"--profile "django"quiet
Default: false
Do not print diffs, the progress bar or the summary.
quiet=truequiet=true"quiet": true--quietquote_style
Default: "double"
Quotes for strings inside template tags, double or single. T002 asks for the same quotes, and the formatter uses them in conditions such as {% if x == "a" %}, so one file does not spell the same string both ways. Quoting of HTML attributes is left to H008.
quote_style="single"quote_style="single""quote_style": "single"--quote-style singlerequire_pragma
Default: false
Only format or lint files that start with a djlint:on comment. It can be an HTML comment or one in the template language of the profile, and without a profile, one in any of them.
<!-- djlint:on -->{# djlint:on #}{% comment %} djlint:on {% endcomment %}{{ /* djlint:on */ }}{{!-- djlint:on --}}require_pragma=truerequire_pragma=true"require_pragma": true--require-pragmarules
A custom rules file in the .djlint_rules.yaml format, read instead of the one in the project root.
--rules ../shared/.djlint_rules.yamlsarif
Default: false
Print the findings as a SARIF 2.1.0 document, for GitHub code scanning and other tools. See GitHub Actions.
--sarifsingle_attribute_per_line
Default: false
When an opening tag wraps, put the tag name, each attribute and the closing bracket on separate lines.
single_attribute_per_line=truesingle_attribute_per_line=true"single_attribute_per_line": true--single-attribute-per-linesort_attributes
Default: false
Sort attributes by name, with id first and class second. A tag whose attributes are guarded by a template tag keeps the order it was written in, since moving one out of its branch would change the page.
sort_attributes=truesort_attributes=true"sort_attributes": true--sort-attributessort_load_tags
Default: false
Sort the libraries in {% load %} tags and drop the ones written twice, so {% load static i18n %} becomes {% load i18n static %}. In {% load a b from library %} the names before from are sorted. Where two libraries define a tag or filter of the same name, the one loaded last wins, so sorting can change which one the template uses.
sort_load_tags=truesort_load_tags=true"sort_load_tags": true--sort-load-tagsstatistics
Default: false
After linting, print how many times each code was found.
--statisticsstdin_filename
Default: "-"
Path that stands for stdin in messages and when matching exclude and per-file-ignores.
--stdin-filename templates/index.htmluse_gitignore
Default: false
Also skip the paths that the .gitignore in the project root lists.
use_gitignore=trueuse_gitignore=true"use_gitignore": true--use-gitignoreversion
Show the version and exit.
--versionwarn
Default: false
Exit with 0 instead of 1 when there are lint errors or files to reformat.
--warn