skillfed

chompjs

Parsing JavaScript objects into Python dictionaries

chompjs v1.4.1 98.1K downloads/30d#13,106 on PyPI222
Permissive license Active released

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 chompjs

uv

uv add chompjs

poetry

poetry add chompjs

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: JavaScriptProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: GeneralTopic :: Text Processing :: Linguistic

Tags

javascript object parserparse js to python dictweb scraping json extractionjson5 parser pythonjavascript syntax to python
web-scrapingjavascript-parsingjson5

More Python Modules packages