skillfed

html-to-json

Convert html to json.

html-to-json v3.0.0 321.9K downloads/30d#7,617 on PyPI54
Permissive license MIT License Active released

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-json

uv

uv add html-to-json

poetry

poetry add html-to-json

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

html to json conversionparse html as jsonhtml table to jsonextract html structure jsonhtml scraping json outputconvert html markup jsonhtml parsing library
html-parsingdata-extractionweb-scraping

More HTML packages