json-with-comments
JSON with Comments (jsonc) for Python
What it is and what it does
json-with-comments is a Python library that extends JSON parsing to handle comments and trailing commas—features common in configuration files but not part of the JSON specification. It provides load/loads functions that strip single-line (//) and block (/* */) comments before parsing, and dump/dumps functions that can add comments and trailing commas when serializing.
The package has no external dependencies and supports Python 3.7 through 3.13 on both CPython and PyPy. Use it when you need to read or write JSON-like configuration files that include comments, or when working with JSONC format commonly found in configuration tools.
Use it for:
- Parse configuration files in JSONC format that include comments and trailing commas.
- Strip comments from JSON during a preprocessing step before passing to strict JSON parsers.
- Serialize Python objects to JSON while preserving or adding explanatory comments for readability.
- Handle hand-edited JSON files that developers have annotated with trailing commas and comments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and serializes JSON with support for single-line and block comments, plus trailing commas in arrays and objects.
Yes. The package is actively maintained, has no dependencies, installs easily, carries a permissive MIT license, and solves a real problem for anyone working with JSONC files or commented JSON. No known vulnerabilities. Install it if you need to parse or generate JSON with comments.
Install
json-with-comments on PyPI
pip
pip install json-with-commentsuv
uv add json-with-commentspoetry
poetry add json-with-commentsInstalling json-with-comments
Before you install
Low friction: pure Python wheel, no runtime dependencies, and actively maintained with a recent commit on 2026-08-07.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install json-with-comments
import json_with_comments
result = json_with_comments.loads('{"key": "value" /* comment */}')
print(result)
Verify before relying
- Whether dump/dumps comment-addition features work with arbitrary Python objects or only specific types.
- Performance characteristics when parsing large JSON files with extensive comments.
- How the module's import name relates to the package name json-with-comments.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 612 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 136,908/month — #11,381 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_with_comments-1.2.10-py3-none-any.whl
Keywords: json with comments, jsonc
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
json-tricksExtends Python's JSON serialization to handle…
permissive · top 15,000 on PyPI
jsonc-parserParses JSON files with comments (.jsonc) and…
permissive · top 15,000 on PyPI
jsoncommentParses JSON with comments, multiline strings,…
permissive · top 15,000 on PyPI
jstylesonParses JSON strings that contain…
permissive · top 15,000 on PyPI
json5kitParses JSON5 (JSON with comments, trailing…
permissive · top 15,000 on PyPI
JSON_minifyMinifies JSON by removing whitespace and…
permissive · top 15,000 on PyPI
json-repairParses and repairs malformed JSON strings from…
permissive · top 1,000 on PyPI
json5Parses and writes JSON5 data format, which…
permissive · top 1,000 on PyPI
ast-commentsExtends Python's built-in `ast` module to…
permissive · top 15,000 on PyPI
python-rapidjsonFast JSON serialization and deserialization…
permissive · top 5,000 on PyPI