chompjs
Parsing JavaScript objects into Python dictionaries
What it is and what it does
Chompjs is a JavaScript-to-Python object parser designed for web scraping. It transforms JavaScript objects embedded in HTML pages into valid Python dictionaries, handling syntax that the standard library's json.loads rejects—such as unquoted keys, single-quoted strings, trailing commas, and leading-decimal floats. The library uses a C-based parser to normalize the input, then passes the result to json.loads for final conversion, balancing speed with correctness.
The package supports JSON5 syntax and offers two main functions: parse_js_object for extracting a single object (raises ValueError on failure) and parse_js_objects as a generator for multiple objects or JSON Lines. It integrates easily into web scrapers and allows custom JSON loaders and loader options to be passed through.
Use it for:
- Extract __NEXT_DATA__ or __PRELOADED_STATE__ from server-rendered web pages during scraping.
- Parse JavaScript configuration objects embedded in HTML script tags into Python dicts.
- Read JSON Lines files that may contain JavaScript-style syntax variations.
- Handle web pages where JSON is embedded with unquoted keys or single quotes instead of double quotes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses JavaScript objects embedded in HTML or text into Python dictionaries, handling JavaScript syntax that standard JSON parsers reject.
Yes. Chompjs solves a real web-scraping problem—parsing non-standard JavaScript objects that json.loads cannot handle—with active maintenance, no security vulnerabilities, permissive licensing, and broad platform support. Install friction is moderate but manageable; prebuilt wheels cover modern Python versions and common architectures.
Install
chompjs on PyPI
pip
pip install chompjsuv
uv add chompjspoetry
poetry add chompjsInstalling chompjs
Before you install
Medium install friction due to compiled C extension wheels, but well-supported across modern Python versions on major platforms (macOS ARM64, Linux x86_64, Windows). Active maintenance with recent release.
License in practice
MIT license (permissive); no restrictions on use, modification, or redistribution in commercial or private projects.
Quickstart
pip install chompjs
import chompjs
# Parse single JavaScript object
result = chompjs.parse_js_object("{a: 100}")
print(result) # {'a': 100}
# Parse multiple objects from text
for obj in chompjs.parse_js_objects("{'x': 1}\n{'y': 2}"):
print(obj)
Requires Python 3.9 or later; compiled wheels available for common platforms but source build may require a C compiler.
Verify before relying
- Performance comparison to other JavaScript parsers under typical scraping workloads.
- Whether the C parser handles all edge cases of JavaScript object syntax or has known limitations.
- Specific Python version support beyond the stated 3.9 minimum requirement.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 89 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 98,116/month — #13,106 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: chompjs-1.4.1-cp310-cp310-macosx_11_0_arm64.whl; chompjs-1.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; chompjs-1.4.1-cp310-cp310-musllinux_1_2_x86_64.whl; chompjs-1.4.1-cp310-cp310-win32.whl; chompjs-1.4.1-cp310-cp310-win_amd64.whl; chompjs-1.4.1-cp311-cp311-macosx_11_0_arm64.whl; chompjs-1.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; chompjs-1.4.1-cp311-cp311-musllinux_1_2_x86_64.whl; chompjs-1.4.1-cp311-cp311-win32.whl; chompjs-1.4.1-cp311-cp311-win_amd64.whl; chompjs-1.4.1-cp312-cp312-macosx_11_0_arm64.whl; chompjs-1.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; chompjs-1.4.1-cp312-cp312-musllinux_1_2_x86_64.whl; chompjs-1.4.1-cp312-cp312-win32.whl; chompjs-1.4.1-cp312-cp312-win_amd64.whl; chompjs-1.4.1-cp313-cp313-macosx_11_0_arm64.whl; chompjs-1.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; chompjs-1.4.1-cp313-cp313-musllinux_1_2_x86_64.whl; chompjs-1.4.1-cp313-cp313-win32.whl; chompjs-1.4.1-cp313-cp313-win_amd64.whl
Keywords: parsing, parser, JavaScript, json, json5, webscrapping
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
json5Parses and writes JSON5 data format, which…
permissive · top 1,000 on PyPI
json5kitParses JSON5 (JSON with comments, trailing…
permissive · top 15,000 on PyPI
fix-busted-jsonRepairs malformed JSON strings by fixing common…
permissive · top 15,000 on PyPI
pybacklogpyPyBacklogPy wraps the Backlog API to let you…
permissive · top 5,000 on PyPI
demjson3demjson3 encodes, decodes, and validates JSON…
copyleft · top 15,000 on PyPI
partialjsonParses incomplete or malformed JSON strings…
permissive · top 15,000 on PyPI
pyjson5Parses and serializes JSON5 (a more lenient…
permissive · top 5,000 on PyPI
dirtyjsonParses JSON-like data from files containing…
permissive · top 5,000 on PyPI
itemloadersItemloaders extracts and standardizes…
permissive · top 5,000 on PyPI
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI