json-five
A JSON5 parser that, among other features, supports round-trip preservation of comments
What it is and what it does
json-five is a JSON5 parser and serializer for Python that extends standard JSON handling to support JSON5—a relaxed JSON format allowing comments, unquoted object keys, trailing commas, and other conveniences. It provides two main interfaces: a simple loads/dumps API mirroring the standard library's json module, and a lower-level abstract model API for advanced use cases like linting, formatting, and custom serialization.
The package is designed to preserve non-data elements (comments, formatting, identifier styles) during round-trip operations, so you can load JSON5, modify it programmatically, and dump it back while keeping the original structure intact. It depends on sly and regex and is actively maintained with support for Python 3.8 through 3.11.
Use it for:
- Load configuration files written in JSON5 format with comments and relaxed syntax into Python dictionaries.
- Build linters or formatters that parse JSON5 and preserve comments and formatting during output.
- Edit JSON5 documents programmatically using the abstract model API while maintaining original comments and structure.
- Tokenize JSON5 input for custom analysis or validation workflows.
- Work with JSON5 documents that use unquoted identifiers and other relaxed syntax features.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and serializes JSON5 (an extended JSON format with comments, unquoted keys, and trailing commas) with an interface similar to Python's standard json module, plus support for round-trip preservation of comments and formatting.
Yes. The package is actively maintained, has low install friction, carries a permissive Apache license, and fills a genuine gap for JSON5 support in Python. It is well-suited for configuration parsing and round-trip editing. The abstract model API is marked unstable, so avoid it if you need long-term compatibility guarantees, but the core loads/dumps interface is stable as of v1.0.0.
Install
json-five on PyPI
pip
pip install json-fiveuv
uv add json-fivepoetry
poetry add json-fiveInstalling json-five
Before you install
Low friction: pure Python wheel, two lightweight runtime dependencies (sly and regex), and active maintenance with a recent commit on 2026-07-27. Supports Python 3.8 and later versions.
License in practice
Apache License (permissive): you can use this package in commercial and private projects without restriction, though you must include a copy of the license and state any modifications.
Quickstart
pip install json-five
import json5
json_text = '{foo: "bar"} // comment'
data = json5.loads(json_text)
print(data)
Requires Python 3.8 or later; the import name is json5, not json_five.
Verify before relying
- Performance characteristics when parsing large JSON5 files or deeply nested structures.
- Stability guarantees for the abstract model API beyond v1.0.0 (marked subject to breaking changes in minor releases).
- Real-world usage patterns and community feedback on the model-based loader for linting and formatting workflows.
Package facts
| License | Apache (permissive) |
| Python support | supports the current Python release (>=3.8.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — sly, regex |
| Maintenance | actively maintained — 794 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 143,860/month — #11,165 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_five-1.1.2-py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 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
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI
pyjson5Parses and serializes JSON5 (a more lenient…
permissive · top 5,000 on PyPI
json-with-commentsParses and serializes JSON with support for…
permissive · top 15,000 on PyPI
jsonableProvides an abstract base class for defining…
permissive · top 15,000 on PyPI
partialjsonParses incomplete or malformed JSON strings…
permissive · top 15,000 on PyPI
chompjsParses JavaScript objects embedded in HTML or…
permissive · top 15,000 on PyPI
jsonsConverts Python objects (dataclasses, attrs…
permissive · top 5,000 on PyPI