json5kit
A Roundtrip parser and CST for JSON, JSONC and JSON5.
What it is and what it does
json5kit is a parser and code transformer for JSON5—a JSON superset that allows comments, trailing commas, unquoted object keys, and single-quoted strings. It builds a concrete syntax tree (CST) that preserves the original source structure, so you can parse JSON5, modify it programmatically, and convert it back to source while keeping comments and formatting intact, or export it as standard JSON.
The package has no runtime dependencies and supports Python 3.7 and later. It provides a visitor pattern for tree traversal and transformation, letting you inspect and modify parsed values while maintaining the source representation. This is useful for configuration files, build scripts, or any JSON-like format where readability and comments matter.
Use it for:
- Parse and edit configuration files written in JSON5 while preserving user comments and formatting
- Convert JSON5 config files to standard JSON for consumption by tools that only accept strict JSON
- Build linters or formatters for JSON5 that need to understand and modify the syntax tree
- Programmatically transform JSON5 data structures using visitor patterns without losing source fidelity
- Support JSONC (JSON with comments) in applications that currently expect strict JSON
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses JSON5 (JSON with comments, trailing commas, unquoted keys) into a concrete syntax tree and converts it back to source or standard JSON while preserving formatting and comments.
Yes, if you need to parse JSON5 or JSONC and preserve formatting or comments. The package is stable and has no dependencies, making it low-risk to add. However, maintenance is dormant (no updates since May 2023), so if you hit edge cases or need new JSON5 features, you may need to fork or patch it yourself.
Install
json5kit on PyPI
pip
pip install json5kituv
uv add json5kitpoetry
poetry add json5kitInstalling json5kit
Before you install
Low friction; no runtime dependencies. Maintenance is dormant (last release May 2023, last commit October 2023), so expect no active bug fixes or feature updates.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install json5kit
import json5kit
source = '{items: [1, 2, 4], // comment}'
tree = json5kit.parse(source)
print(tree.to_source()) # preserves formatting
print(tree.to_json()) # standard JSON output
Verify before relying
- Extent of JSON5 syntax coverage beyond comments, trailing commas, and unquoted keys
- Performance characteristics on large files or deeply nested structures
- Whether transformer API supports all node types or only a subset
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,186 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,138/month — #13,746 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json5kit-0.4.0-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
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
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
json5Parses and writes JSON5 data format, which…
permissive · top 1,000 on PyPI
jsonc-parserParses JSON files with comments (.jsonc) and…
permissive · top 15,000 on PyPI
json-with-commentsParses and serializes JSON with support for…
permissive · top 15,000 on PyPI
jsoncommentParses JSON with comments, multiline strings,…
permissive · top 15,000 on PyPI
libcstlibcst parses Python source code into a…
permissive · top 1,000 on PyPI
dirtyjsonParses JSON-like data from files containing…
permissive · top 5,000 on PyPI
jstylesonParses JSON strings that contain…
permissive · top 15,000 on PyPI
partialjsonParses incomplete or malformed JSON strings…
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