skillfed

pyjson5

JSON5 serializer and parser for Python 3 written in Cython.

pyjson5 v2.0.1 2.8M downloads/30d#2,901 on PyPI179
Permissive license MIT OR Apache-2.0 Active released

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 pyjson5

uv

uv add pyjson5

poetry

poetry add pyjson5

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: CythonProgramming Language :: JavaScriptProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Free Threading :: 2 - BetaProgramming Language :: Python :: Implementation :: CPythonTopic :: Text Processing :: General

Tags

json5 parser pythonjson5 serializerlenient json parsingjson5 encoder decoderhtml-safe json serializationjson5 cythonparse json5 format
json5html-safe-serializationcython-compiled

More General packages