html-to-json
Convert html to json.
What it is and what it does
html-to-json is a Python library that transforms HTML markup into JSON structures. It provides two main conversion functions: one for general HTML documents that preserves element hierarchy, attributes, and text content, and another specialized for HTML tables that intelligently extracts rows and columns into JSON objects keyed by header names. The library depends on beautifulsoup4 for HTML parsing and supports modern Python versions from 3.10 onward.
The package handles three common table patterns: headers in the first row, headers in the first column, or no headers at all. For both HTML and table conversion, you can control what gets captured—text values, attributes, nested tags as inner HTML, or nested tags as structured JSON—via keyword arguments. This makes it useful for web scraping workflows, data extraction pipelines, and converting HTML reports into machine-readable formats.
Use it for:
- Extract structured data from HTML tables on web pages and convert to JSON for further processing.
- Parse HTML documents from web scraping operations and transform into JSON for storage or API responses.
- Convert HTML-based reports or exports into JSON format for integration with downstream data pipelines.
- Preserve HTML attributes and nested link structures when extracting table data by using record_html or record_children options.
- Build data ingestion tools that accept HTML input and output standardized JSON for consumption by other services.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts HTML documents and HTML tables into JSON structures, optionally capturing element attributes, text values, and nested tags.
Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a concrete problem—converting HTML to JSON—with a straightforward API. It's suitable for production use in web scraping and data extraction workflows where HTML tables or documents need to become JSON.
Install
html-to-json on PyPI
pip
pip install html-to-jsonuv
uv add html-to-jsonpoetry
poetry add html-to-jsonInstalling html-to-json
Before you install
Low friction installation with a single runtime dependency (beautifulsoup4). The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely as long as you include the license notice.
Quickstart
pip install html-to-json
import html_to_json
html_string = "<html><head><title>Test</title></head></html>"
output_json = html_to_json.convert(html_string)
print(output_json)
Requires Python 3.10 or later.
Verify before relying
- Performance characteristics when processing large HTML documents or tables with many rows.
- Behavior with malformed or non-standard HTML input.
- Memory usage patterns for deeply nested HTML structures.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — beautifulsoup4 |
| Maintenance | actively maintained — 93 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 321,894/month — #7,617 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: html_to_json-3.0.0-py3-none-any.whl
Keywords: conversion, html, html to json, json
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
html-for-docxConverts HTML content to Word documents…
permissive · top 15,000 on PyPI
html-table-parser-python3Parses HTML tables into nested lists of rows…
agpl · top 15,000 on PyPI
prettierfierReformats HTML and XML strings with intelligent…
permissive · top 15,000 on PyPI
soup2dictConverts BeautifulSoup4 parsed HTML or XML…
permissive · top 15,000 on PyPI
xlsx2htmlConverts Excel spreadsheets (.xlsx files) to…
permissive · top 15,000 on PyPI
xmltojsonConverts XML documents to JSON format via a…
permissive · top 15,000 on PyPI
Selenium-ScreenshotCaptures full-page or element-level screenshots…
permissive · top 15,000 on PyPI
hyperscriptHyperscript lets you generate HTML markup…
permissive · top 15,000 on PyPI
premailerConverts CSS style blocks into inline style…
permissive · top 5,000 on PyPI
w3libw3lib provides utility functions for common web…
permissive · top 5,000 on PyPI