Skip to content

Django HTML Template Formatter

Format Django HTML templates with djLint's Django profile. Paste a non-sensitive snippet, select Format HTML, then review and copy the result. The formatter adjusts layout without rendering your template variables. For private code or whole projects, use the local commands below instead of sending templates to this server.

Paste a Django template or load the example, select Format HTML, then copy the result.

Formatting runs on our server, not only in your browser. Do not paste secrets, customer data, or confidential templates.

Try a non-sensitive loop with template variables. Loading it does not submit the template or replace your input.

Format a Django template, not its rendered output

Use the source from your .html template, including Django tags and variables. HTML copied from a browser's page source has already been rendered and cannot recover the original template logic. This tool runs djLint with --reformat --profile=django; it does not run your Django view, look up context variables, or execute template tags.

A small before-and-after example

This example uses Django 5.2's for and empty tags. The output below was checked with djLint 1.36.4 on October 11, 2026. Use Load Django example above, then select Format HTML to try this input.

Before

<ul>{% for project in projects %}<li>{{ project.name }}</li>{% empty %}<li>No projects yet.</li>{% endfor %}</ul>

After

<ul>
    {% for project in projects %}
        <li>{{ project.name }}</li>
    {% empty %}
        <li>No projects yet.</li>
    {% endfor %}
</ul>

The loop and variable remain template source; the formatter does not replace them with project names. Check the diff before using the result. In particular, review whitespace around inline elements and in whitespace-sensitive content, then render the template in your application.

Format private templates locally

For a file on your own computer, use djLint's check and reformat commands with its Django profile. These commands use the same tested version as the example and require uv to be installed.

uvx --from djlint==1.36.4 djlint templates/example.html --check --profile=django
uvx --from djlint==1.36.4 djlint templates/example.html --reformat --profile=django

Replace templates/example.html with your file path. The first command shows proposed changes; the second rewrites the file. Run them from your project directory so djLint can read your configuration. The first run may download djLint; formatting happens locally, without uploading the template to this tool. When you are ready to automate it, follow the djLint section of our Django pre-commit guide.

Does formatting prove a template is correct?

No. djLint's formatter is not an HTML parser or syntax validator. A formatted result does not prove that a custom tag exists, a context variable is present, or the page is accessible or secure. Review the output and run your application's tests. For template setup, start with our basic Django setup tutorial; for examples of real applications, browse open-source Django projects.

Usage guidance updated .

The Django newsletter

Weekly Django projects and practical tutorials. Confirm your email to join; unsubscribe anytime.