Install & Compatibility
Where this runs
tested against v31.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
main
✓ from junit2htmlreport import main
✗ from junit2htmlreport import main
Junit2Html
✓ from junit2htmlreport import Junit2Html
junit2htmlreport
✓ import junit2htmlreport
The primary way to use junit2html is through its command-line interface. This quickstart demonstrates how to create a dummy JUnit XML file and then convert it into an HTML report using the `junit2html` command or its module-based execution.
# Create a dummy JUnit XML file for demonstration
# In a real scenario, this would be generated by your test runner (e.g., pytest --junitxml=results.xml)
import os
dummy_xml_content = '''
<testsuites>
<testsuite name="MyTestSuite" tests="2" failures="1" errors="0" skipped="0" time="0.123">
<testcase classname="test_module.TestClass" name="test_passing_case" time="0.050"/>
<testcase classname="test_module.TestClass" name="test_failing_case" time="0.073">
<failure message="AssertionError: 1 != 2">Traceback (most recent call last):...</failure>
</testcase>
</testsuite>
</testsuites>
'''
with open('results.xml', 'w') as f:
f.write(dummy_xml_content)
# Run junit2html from the command line
# This is the primary usage pattern.
# The 'junit2html' command should be available in your PATH after installation.
# Alternatively, use 'python -m junit2htmlreport results.xml report.html'
import subprocess
try:
# Using the installed CLI command
subprocess.run(['junit2html', 'results.xml', 'report.html'], check=True)
print("HTML report 'report.html' generated successfully.")
except FileNotFoundError:
print("'junit2html' command not found. Trying 'python -m junit2htmlreport'.")
try:
# Fallback to module execution
subprocess.run(['python', '-m', 'junit2htmlreport', 'results.xml', 'report.html'], check=True)
print("HTML report 'report.html' generated successfully via module execution.")
except subprocess.CalledProcessError as e:
print(f"Error generating report: {e}")
except subprocess.CalledProcessError as e:
print(f"Error generating report: {e}")
# Clean up dummy XML (optional)
os.remove('results.xml')
junit2html --version
Upgrade
Version history
31.1.4latest on PyPI · released Jun 11, 2026
Audit
Dependencies
jinja2requiredUsed for templating the HTML reports.