skillfed

json5kit

A Roundtrip parser and CST for JSON, JSONC and JSON5.

json5kit v0.4.0 88.1K downloads/30d#13,746 on PyPI21
Permissive license MIT DORMANT released

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 json5kit

uv

uv add json5kit

poetry

poetry add json5kit

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTyping :: Typed

Tags

json5 parserparse json with commentsroundtrip json parserconcrete syntax tree jsonjson5 to json converterjsonc parserpreserve json formatting
json-parsercstroundtrip

More Text Processing packages