dirtyjson
JSON decoder for Python that can extract data from the muck
What it is and what it does
dirtyjson is a JSON decoder that reads JSON-like data from files violating the official JSON standard. It accepts single quotes, line and inline comments, dangling commas, unquoted single-word keys, and hexadecimal/octal number literals. The parser returns Python objects wrapped in AttributedDict and AttributedList subclasses that preserve line and column position metadata for every element, allowing you to map results back to source locations.
The package is designed for extracting structured data from JavaScript files or other sources where strict JSON compliance is not guaranteed. It exposes a familiar API similar to the standard library's json module, offering load() and loads() functions but no write capability. Position tracking makes it useful for building error messages or source-aware parsers that need to report exactly where in the original file a problem occurred.
Use it for:
- Extract configuration objects from JavaScript files that use unquoted keys or trailing commas.
- Parse JSON responses from APIs or data files that include comments or non-standard syntax.
- Build a linter or code analyzer that needs to report errors with precise line and column references.
- Read JSON-like data embedded in source code where strict compliance is impractical.
- Migrate legacy systems that generate or consume non-standard JSON variants.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses JSON-like data from files containing syntax violations—single quotes, comments, unquoted keys, dangling commas, and hex/octal numbers—while tracking line and column positions for each element.
Yes, if you need to parse non-standard JSON and can tolerate abandoned maintenance. The package is stable, has no dependencies, and works reliably for its core purpose. However, do not install if you require active bug fixes, security updates, or support for future Python versions—the last commit was 2022-11-28 and the project shows no signs of revival. For new projects, consider whether standard JSON with preprocessing might be more maintainable.
Install
dirtyjson on PyPI
pip
pip install dirtyjsonuv
uv add dirtyjsonpoetry
poetry add dirtyjsonInstalling dirtyjson
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is inactive—last commit was 2022-11-28 and shows no recent activity. Suitable for stable, read-only use cases but not for active development or bug fixes.
License in practice
Dual-licensed under MIT License and Academic Free License (AFL), both permissive. You may use, modify, and distribute freely in proprietary or open-source projects with minimal restrictions.
Quickstart
import dirtyjson
data = dirtyjson.loads("[\"foo\", /* comment */ {bar: ['baz', null, 1.0, 2,]}]")
print(data)
pos = data.attributes(0)
print(pos.line, pos.column)
Verify before relying
- Whether the package handles modern Python versions beyond 3.10 without issues given abandoned maintenance status.
- Performance characteristics when parsing very large or deeply nested JSON-like structures.
- Compatibility with recent versions of PyPy if that is a deployment target.
Package facts
| License | MIT License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,355 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 11,617,464/month — #1,379 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dirtyjson-1.0.8-py3-none-any.whl
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
demjson3demjson3 encodes, decodes, and validates JSON…
copyleft · top 15,000 on PyPI
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI
json-source-mapMaps each value in a JSON document to its…
permissive · top 15,000 on PyPI
poyoParses a restricted subset of YAML into Python…
permissive · top 15,000 on PyPI
json5kitParses JSON5 (JSON with comments, trailing…
permissive · top 15,000 on PyPI
partial-json-parserParses incomplete JSON strings generated by LLM…
permissive · top 5,000 on PyPI
json-with-commentsParses and serializes JSON with support for…
permissive · top 15,000 on PyPI
simplejsonsimplejson encodes Python objects to JSON and…
permissive · top 1,000 on PyPI
biocReads and writes biomedical text annotation…
permissive · top 15,000 on PyPI
chompjsParses JavaScript objects embedded in HTML or…
permissive · top 15,000 on PyPI