docx-jinja2-validator
Validate Jinja2 template syntax inside .docx files — built for use with docxtpl.
Install
pip install docxlint
Usage
# single file
docxlint template.docx
# entire folder
docxlint ./templates/
# recursive (includes subfolders)
docxlint ./templates/ --recursive
# verbose (show all block tags)
docxlint ./templates/ --verbose
Or via Python module:
python -m docxlint template.docx
What it checks
| # | Check | Example error caught |
|---|---|---|
| 1 | Valid ZIP / DOCX structure | Corrupt file |
| 2 | XML well-formedness | word/document.xml broken |
| 3 | {{ }} balance |
Missing } in variable |
| 4 | {% %} balance |
Missing %} in block tag |
| 5 | Split tags | Word splits {{var}} across XML runs |
| 6 | Common typos | {{{, }}}, { %, % }, end for |
| 7 | Block pairing | {% for %} without {% endfor %} |
| 8 | Table row tags | {%tr for %} without {%tr endfor %} |
| 9 | Variable inventory | Lists all {{ ... }} found |
Example output
Validating: template.docx (42 KB)
────────────────────────────────────────────────────────────
1. DOCX structure
✓ Valid ZIP with 17 entries
✓ word/document.xml present
2. XML well-formedness
✓ word/document.xml
3. Jinja2 syntax
✓ word/document.xml: 6 variables, 4 block tags
4. Block tag pairing
✓ All for/if blocks properly closed
5. Table row tags {%tr %}
✓ word/document.xml: 1 table row loop(s) matched
6. Variable inventory
→ Found 6 unique variable expression(s):
{{ objects.customer_id.name }}
{{ objects.total_overdue_amount }}
...
Result
✓ PASSED
Exit codes
| Code | Meaning |
|---|---|
0 |
All files passed |
1 |
One or more files have issues |
Useful for CI/CD pipelines:
docxlint ./templates/ && echo "Templates OK" || echo "Fix templates!"
Use as a library
from docxlint import validate_one
from pathlib import Path
result = validate_one(Path("template.docx"), verbose=False)
print(result.passed) # True / False
print(result.issues) # number of failed checks
License
MIT
Metadata
Release files for docxlint 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docxlint-0.1.0.tar.gz | 8.8 kB | Without provenance | Details for docxlint-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docxlint-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for docxlint-0.1.0-py3-none-any.whl |
Total release size: 17.5 kB
Release files / docxlint-0.1.0.tar.gz
| Download URL | docxlint-0.1.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72e76174029bdba11e7ed75f9e2730ef9ec0a4c2d67d66eb3c11e821067a2159
|
|
BLAKE2b-256 checksum How to use checksums |
56a07e3fe96d48310d3fa0e6ffffdfc19408c06c596cd8bae5bfaa298ce12b6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.7
|
Release files / docxlint-0.1.0-py3-none-any.whl
| Download URL | docxlint-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aecf01cd295589640f4b2ed73a0875ab9969014b6e2b754b61622f61a6c8d1f6
|
|
BLAKE2b-256 checksum How to use checksums |
cf49603c4d66a787f2b01dba9235c00584cec0773f876efbbd4e63cc23f50f2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.7
|
Security for docxlint 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.