skillfed

dirtyjson

JSON decoder for Python that can extract data from the muck

dirtyjson v1.0.8 11.6M downloads/30d#1,379 on PyPI49
Permissive license MIT License Abandoned released

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 dirtyjson

uv

uv add dirtyjson

poetry

poetry add dirtyjson

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Academic Free License (AFL)License :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.5Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

lenient json parserjson with commentsparse malformed jsondirty json decoderjavascript object extractionjson position trackingrelaxed json parsing
json-parsingposition-trackinglenient-parsing

More Python Modules packages