Skip to main content

A package to parse out C/JS style block and single line comments from JSON files

Project description

Build Status PyPI version GitHub license PyPI pyversions


A Python library for parsing out C/Javascript style comments in JSON files.


pip install jsonjsc


  1. Simple and easy to use library with no other dependencies.
  2. Supports C/JS block (/* */) and single line (//) comments.
  3. Retains the line number and character column of JSON content after parsing, letting syntax error positions get properly reported by the normal Python JSON decoder.
  4. Is easily dropped into existing JSON library usage as a decoder class.
  5. Test backed via unittest.


import json
import jsonjsc

    This is a test of the JSON decoder in full
    "test1": "message1", // this comment should parse out.

    // "junk1": "message",

    "junk2": "another message",

    "test2": "message2"

test = json.loads(TEST_JSON_DECODER, cls=jsonjsc.JSONCommentDecoder)


if "junk1" not in test:
    print("I guess junk1 was commented out?")

if "junk2" not in test:
    print("I guess junk2 was commented out too!")



Implementation could probably be sped up significantly as it uses character by character searches to test if comments are in string values or not. No performance metrics have been taken.


Licensed under the MIT License. See LICENSE for more information.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsonjsc, version 1.1.2
Filename, size File type Python version Upload date Hashes
Filename, size jsonjsc-1.1.2-py2.py3-none-any.whl (4.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size jsonjsc-1.1.2.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page