pyjson5
JSON5 serializer and parser for Python 3 written in Cython.
What it is and what it does
pyjson5 is a JSON5 parser and serializer written in Cython for Python 3. JSON5 is a more permissive variant of JSON that allows unquoted keys, trailing commas, comments, and other relaxations of strict JSON syntax. The library also handles standard JSON, making it a potential drop-in replacement for Python's built-in json module.
The serializer produces ASCII output with apostrophes, ampersands, and angle brackets encoded as Unicode escapes, making it safe for direct use in HTML templates without additional escaping. The parser handles all valid JSON5 1.0.0 and JSON data. The package has no runtime dependencies and supports Python 3.8 through 3.14, including recent CPython free-threading beta support.
Use it for:
- Parse configuration files in JSON5 format that allow comments and unquoted keys
- Serialize Python objects to JSON for embedding directly in HTML templates without HTML-escaping vulnerabilities
- Handle JSON data with trailing commas or other JSON5 relaxations from external sources
- Replace the standard json module when lenient parsing of JSON-like input is needed
- Generate JSON output safe for use in JavaScript contexts within web pages
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and serializes JSON5 (a more lenient JSON variant) and standard JSON in Python, with output safe for HTML templates.
Yes. The package is actively maintained, production-stable, has no dependencies, supports current Python versions, carries no known vulnerabilities, and solves a real problem—parsing lenient JSON5 and generating HTML-safe JSON output. Install it if you need JSON5 support or HTML-safe serialization; otherwise the standard json module suffices.
Install
pyjson5 on PyPI
pip
pip install pyjson5uv
uv add pyjson5poetry
poetry add pyjson5Installing pyjson5
Before you install
Medium install friction due to compiled wheels; actively maintained with recent commits and stable production status. No runtime dependencies simplifies deployment.
License in practice
Dual-licensed under MIT or Apache-2.0 (permissive); you may choose either license for your use, with no restrictions on commercial or proprietary projects.
Quickstart
pip install pyjson5
import pyjson5
data = pyjson5.loads('{a: 1, b: 2}') # Parse JSON5
result = pyjson5.dumps(data) # Serialize to JSON
Requires Python 3.8 or later; CPython 3.8+ or recent PyPy3 version needed.
Verify before relying
- Performance characteristics compared to standard json module for typical workloads
- Specific nesting depth limit before 'absurdly high' threshold is reached
- Whether HTML-safe escaping is applied by default or requires explicit configuration
Package facts
| License | MIT OR Apache-2.0 (permissive) |
| Python support | supports the current Python release (~=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 91 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,759,922/month — #2,901 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyjson5-2.0.1-cp310-cp310-macosx_10_9_universal2.whl; pyjson5-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl; pyjson5-2.0.1-cp310-cp310-macosx_11_0_arm64.whl; pyjson5-2.0.1-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl; pyjson5-2.0.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyjson5-2.0.1-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl; pyjson5-2.0.1-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl; pyjson5-2.0.1-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl; pyjson5-2.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyjson5-2.0.1-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_aarch64.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_armv7l.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_i686.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_ppc64le.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_riscv64.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_s390x.whl; pyjson5-2.0.1-cp310-cp310-musllinux_1_2_x86_64.whl; pyjson5-2.0.1-cp310-cp310-win32.whl; pyjson5-2.0.1-cp310-cp310-win_amd64.whl; pyjson5-2.0.1-cp310-cp310-win_arm64.whl
Tags
More General packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
humanizeConverts numbers, dates, times, and file sizes…
permissive · top 1,000 on PyPI
json5Parses and writes JSON5 data format, which…
permissive · top 1,000 on PyPI
simplejsonsimplejson encodes Python objects to JSON and…
permissive · top 1,000 on PyPI
numpyencoderProvides a custom JSON encoder class that…
permissive · top 15,000 on PyPI
py-ubjsonEncodes and decodes data in Universal Binary…
permissive · top 5,000 on PyPI
partialjsonParses incomplete or malformed JSON strings…
permissive · top 15,000 on PyPI
json5kitParses JSON5 (JSON with comments, trailing…
permissive · top 15,000 on PyPI
flask-orjsonReplaces Flask's default JSON encoder with…
permissive · top 15,000 on PyPI
jsonsConverts Python objects (dataclasses, attrs…
permissive · top 5,000 on PyPI
chompjsParses JavaScript objects embedded in HTML or…
permissive · top 15,000 on PyPI
ytsaurus-ysonProvides C++ bindings for serializing and…
permissive · top 15,000 on PyPI