--- id: chompjs version: "1.4.1" license: unclear license_treatment: permissive maintenance: active --- # chompjs — Parsing JavaScript objects into Python dictionaries License: permissive · Maintenance: active · Downloads: 98.1K/mo ## 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 above — 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 pip install chompjs uv add chompjs 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_current - Install friction: medium - Maintenance: active - Downloads: 98.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags javascript object parser, parse js to python dict, web scraping json extraction, json5 parser python, javascript syntax to python, web-scraping, javascript-parsing, json5 [View on SkillFed](https://skillfed.io/packages/chompjs) · [View on PyPI](https://pypi.org/project/chompjs/)