HTML Parsing API

Parse HTML to structured JSON. Headings, tables and lists become the same typed blocks you get from Office files. No AI is involved, so the same page always gives the same result.

HTML Varies Wildly

Clean HTML with proper <h1>, <table> and <article> tags is easy to parse. Most real HTML is not like that. Email clients produce deeply nested table layouts with inline styles. CMS exports mix content markup with styling markup. Scraped web pages carry navigation, ads and boilerplate next to the content.

AILANG Parse removes the styling and layout and keeps the content: headings, paragraphs, tables and lists become typed blocks. The output uses the same block format as DOCX and XLSX parsing, so your code handles every format the same way.

HTML parsing uses no AI, so the same page always gives the same result. Even complex email HTML with nested tables and inline styles parses in under 100ms.
Messy HTML is handled. Attributes with no value (crossorigin, disabled, defer, open, …), overlapping or unclosed tags (<a><p>…</a>), inline <script> blocks containing JSX or template literals, and IE conditional comments all parse.

Raw HTML vs Structured Output

Raw HTML (email newsletter)
<html>
<body style="margin:0;padding:0">
<table width="100%" cellpadding="0">
  <tr><td align="center">
    <table width="600">
      <tr><td>
        <h2 style="font-family:Arial;
          color:#333;font-size:24px;
          margin:0 0 16px">
          Weekly Report
        </h2>
        <p style="font-family:Arial;
          font-size:14px;color:#666;
          line-height:1.5">
          Here are this week's metrics:
        </p>
        <table border="1" cellpadding="8"
          style="border-collapse:collapse;
          width:100%">
          <tr style="background:#f5f5f5">
            <th>Metric</th>
            <th>Value</th>
            <th>Change</th>
          </tr>
          <tr>
            <td>Revenue</td>
            <td>$142K</td>
            <td>+12%</td>
          </tr>
        </table>
      </td></tr>
    </table>
  </td></tr>
</table>
</body></html>
Structured output
{
  "blocks": [
    {
      "type": "heading",
      "level": 2,
      "text": "Weekly Report"
    },
    {
      "type": "text",
      "text": "Here are this week's metrics:"
    },
    {
      "type": "table",
      "headers": [
        {"text": "Metric"},
        {"text": "Value"},
        {"text": "Change"}
      ],
      "rows": [
        [
          {"text": "Revenue"},
          {"text": "$142K"},
          {"text": "+12%"}
        ]
      ]
    }
  ]
}

What Gets Extracted

Heading Hierarchy

Heading tags (<h1> through <h6>) keep their level. Headings made with styling alone (large bold text in a <div> or <span>) are treated as headings where they can be identified.

Tables with Merges

Tables keep their headers (from <thead> or the first row) and rows. Merged cells (colspan/rowspan) are marked with gridSpan/vMerge. Tables used only for layout are dropped and their content kept. Deep dive →

Lists

Ordered (<ol>) and unordered (<ul>) lists come out as text blocks that keep their list style. Nested lists keep their levels.

Content Extraction

Navigation, page headers and footers, ads and boilerplate are removed. The parser finds the main content and returns its text, tables and structure.

Email HTML

Email HTML is harder still. To look right in Outlook, Gmail, Apple Mail and dozens of other mail programs, emails are built from tables with inline styles. A simple newsletter can be 500+ lines of nested <table> tags around a few paragraphs and one data table.

AILANG Parse tells layout tables (used for positioning) apart from data tables (holding real tabular data). Layout tables are dropped and their content kept; data tables keep their full structure. Together with EML parsing, you get an email's headers, metadata and HTML body as structured blocks.

# Parse an HTML file directly
docparse newsletter.html

# Parse an EML with HTML body — both are extracted
docparse newsletter.eml

Use Cases

Web Scraping Pipelines

Parse scraped web pages into structured blocks for indexing, analysis or RAG. Navigation and boilerplate are removed. Tables stay as tables, not flattened text. Headings give you the document outline for chunking.

CMS Content Migration

Export content from WordPress, Drupal or another CMS as HTML, then parse it into structured JSON to move to a new system. Headings, tables and lists carry over. Inline styles and CMS-specific markup are removed.

Email HTML Body Parsing

Extract content from HTML email bodies: newsletter data tables, receipts, shipping notifications. Together with EML parsing, you get the whole email in structured form: headers, plain text, HTML content and attachments.

Documentation Conversion

Convert HTML documentation to Markdown, Quarto or other formats. Headings, code blocks, tables and lists keep their structure. Useful for moving to docs-as-code or publishing in several formats.

AI Knowledge Ingestion

Give LLMs structured blocks instead of raw HTML. The model reads typed headings, paragraphs and tables, not markup, and spends no tokens on <div class="wrapper-outer-inner"> wrappers.

Report Standardization

Turn HTML reports from different sources into one consistent block format. Whether the input is a well-structured report or an email-style table layout, the output is the same typed blocks.

SEC filings. 10-Ks, 10-Qs, S-1s and proxy statements from EDGAR come out with their headings, tables, footnotes and printed page numbers. Explore a 421-page S-1, parsed →

Try It

CLI

# Parse an HTML file
docparse page.html

# Convert HTML to Markdown
docparse page.html --convert output.md

# Convert HTML to DOCX
docparse page.html --convert output.docx

API

curl -X POST https://docparse.ailang.sunholo.com/api/v1/parse \
  -H "Content-Type: application/json" \
  -d '{"filepath":"sample_html","outputFormat":"markdown","apiKey":"YOUR_API_KEY"}'

Python SDK

from ailang_parse import DocParse

client = DocParse(api_key="YOUR_API_KEY")
result = client.parse_file("newsletter.html")

for block in result.blocks:
    if block.type == "heading":
        print(f"H{block.level}: {block.text}")
    if block.type == "table":
        print(f"Table: {len(block.rows)} rows, {len(block.headers)} columns")

Parse in Browser    API Reference

Frequently Asked Questions

How do I parse HTML to structured JSON?

Send the HTML file to the AILANG Parse API or use the Python/JS/Go SDK. The parser turns headings, paragraphs, tables and lists into typed blocks.

Does HTML parsing handle messy or malformed HTML?

Yes. Unclosed tags, nested tables, inline styles and real-world email HTML are all handled. The parser cleans up the markup and keeps the content structure.

Are HTML tables extracted with structure?

Yes. Headers, rows and colspan/rowspan merges are kept. Tables used only for layout are dropped and their content kept. See table extraction docs.

Can I parse email HTML bodies?

Yes. Parse the HTML file directly, or use EML parsing to get the whole email. Layout tables added by email clients are dropped automatically.

Is the output the same as Office format parsing?

Yes. HTML gives the same typed blocks: headings, text, tables, lists. Your code can handle DOCX, XLSX, PPTX and HTML the same way.

How fast is HTML parsing?

Complex email HTML parses in under 100ms. No AI is involved and nothing else needs to be installed.