Registry / testing / junit2html

junit2html

JSON →
library31.1.4pypypi✓ verified 23d ago

junit2html is a lightweight, self-contained Python tool designed to convert JUnit XML test reports into human-readable, single HTML dashboards. It's an essential utility for visualizing test results, especially within CI/CD pipelines, by transforming complex XML data into a clean and responsive HTML file. The current version is 31.0.5, indicating active development with regular updates.

pip install junit2html
INSTALL
IMPORT
SIG · JUNIT2HTML
J
junit2html
testingpythonv31.1.4
Install
1.8s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.1MB
glibc
py 3.103.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
Debug
Known issues
gotchaAfter `pip install junit2html`, the `junit2html` command might not be directly available in your system's PATH. If you encounter a 'command not found' error, try executing it as a Python module: `python -m junit2htmlreport JUNIT_XML_FILE [NEW_HTML_FILE]`.
fix
Use `python -m junit2htmlreport` instead of `junit2html` or ensure your Python scripts directory is in your system PATH.
affects: All versions
gotchajunit2html expects valid JUnit XML format. Input files with non-standard structures, incorrect encodings, or malformed XML (e.g., some outputs from Robot Framework without proper pre-processing) might lead to 'Could not find test suites in results xml' or other parsing errors.
fix
Ensure your JUnit XML input conforms to the standard JUnit XML schema. Validate XML structure if parsing issues occur. Pre-process non-standard XML if necessary before feeding it to junit2html.
affects: All versions
breakingVersion 31.0.4 was yanked from PyPI due to a reported bug. Users who installed this specific version might experience issues. It is recommended to update to 31.0.5 or later.
fix
Upgrade to the latest stable version (e.g., `pip install --upgrade junit2html`) to get critical bug fixes and improvements.
affects: 31.0.4
Upgrade
Version history
31.1.4latest on PyPI · released Jun 11, 2026
Audit
Dependencies
jinja2requiredUsed for templating the HTML reports.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
junit2html — pip install junit2html · libregistry