Skip to main content

html-to-adf - Convert HTML to ADF (Atlassian Document Format)

What is this?

This is a rudimentary python helper module, dedicated to producing Jira/Confluence ready ADF out of incoming HTML.

The module itself attempts to handle generalized sanitization, while cutting some corners to forcibly marshal 'whatever' text into something tangible and compatible with Jira/Confluence.

This module is focused at front-loading incoming comments and descriptions for Jira and follows out of the box a relatively strict subset of tags from HTML.

How to install

We have a pypi package now, so feel free to install through pip: pip install html-to-adf

Dependencies

Everything here is mostly a painfully hand-rolled parser; we have one dependency which is: beautifulsoup4 non-version specific.

Supported and Converted tags

<html> 
<body>

<h1>...<h6>
<head> -> Converted to a heading type
<title> -> Converted to a heading type

<div> -> Converted to a paragraph type
<p>

<table> -> Represents a tablebase
<thead> -> Represents a tablehead
<tbody> -> Represents a tablebody

<tr> -> represents a tablerow
<th> -> represents a tablecell
<td> -> represents a tablecell

Modifiers:

<b>
<strong>
<i>
<em>
<s>
<u>

We also support links and <a> tags. (The magic under the hood can break; usually defaulting to nothing happening at all or your entire line being a link)

Example:

We'll convert the following HTML to ADF:

# test.py
from html_to_adf import import_html_to_str, convert_html_to_adf, export_document

html_text = import_html_to_str("test.html")

# If you were going to send this in an API request format, you would want to structure the ADF around a 'body {}'
# adding True to: convert_html_to_adf(html_text, True) will wrap the entire contents of the dict in a body {} for your ease of use.
resulting_adf_document: dict = convert_html_to_adf(html_text)


print(resulting_adf_document)
export_document(resulting_adf_document)
<!--test.html-->

<html>
  <head>
    <title>Monthly Sales Report</title>
  </head>
  <body>
    <h1>Monthly Sales Report</h1>
    <p>
      The following table shows <b>sales performance</b> by region for 
      <i>September 2025</i>. 
      For more info, visit our 
      <a href="https://example.com/reports/september">report page</a>.
    </p>

    <table>
      <thead>
        <tr>
          <th>Region</th>
          <th>Sales ($)</th>
          <th>Growth</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>North America</td>
          <td><b>125,000</b></td>
          <td><span style="color:green">+5%</span></td>
        </tr>
        <tr>
          <td>Europe</td>
          <td>98,500</td>
          <td><span style="color:red">-2%</span></td>
        </tr>
        <tr>
          <td>Asia-Pacific</td>
          <td>142,750</td>
          <td><u>+8%</u></td>
        </tr>
      </tbody>
    </table>

    <p>
      Summary: <strong>Asia-Pacific</strong> led the month with strong growth.
      <br>
      Keep up the great work!
    </p>
  </body>
</html>

This yields the following ADF: Here's the rather large textblob To view in live time, copy that blob and float on over to the Atlassian Live Document Preview: https://developer.atlassian.com/cloud/jira/platform/apis/document/viewer/

results.png

Further development and support

This module is a creation of necessity, not passion; there's a large chance I won't update it very much, but that said if I get inspired you never know!

Feel free to drop something in the Issues section as you see them and I may visit those issues!

Metadata

Release files for html-to-adf 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html-to-adf 0.1.2
File Size Uploaded
html_to_adf-0.1.2.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html-to-adf 0.1.2
File Interpreter ABI Platform
html_to_adf-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.3 kB

Release files / html_to_adf-0.1.2.tar.gz

Download URL html_to_adf-0.1.2.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f550ed824465d06a439852ebd634d6e89e1171561e72c92497fb93020d4666fa
BLAKE2b-256 checksum
How to use checksums
698182cb936edf38c7b621b93301766ea80868ac5f7f0d8b615b158da6ef2a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / html_to_adf-0.1.2-py3-none-any.whl

Download URL html_to_adf-0.1.2-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ac473019c94fe1bf4f8a33d7e6e401648b62fd3b739fb7539db2b2884f4c65e
BLAKE2b-256 checksum
How to use checksums
9b29a03abe587c0099dfc16a47a8fd872f3c648dc56d814c390faffdd63f7d9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page