diff --git a/commentjson/commentjson.py b/commentjson/commentjson.py
index 4702057..998d383 100755
--- a/commentjson/commentjson.py
+++ b/commentjson/commentjson.py
@@ -26,7 +26,9 @@ except ImportError:
 import lark
 
 from lark import Lark
+from lark.lexer import Token
 from lark.reconstruct import Reconstructor
+from lark.tree import Tree
 
 
 parser = Lark('''
@@ -38,12 +40,13 @@ parser = Lark('''
           | "true"             -> true
           | "false"            -> false
           | "null"             -> null
-    array  : "[" [value ("," value)*] "]"
-    object : "{" [pair ("," pair)*] "}"
+    array  : "[" [value ("," value)*] TRAILING_COMMA? "]"
+    object : "{" [pair ("," pair)*]  TRAILING_COMMA? "}"
     pair   : string ":" value
     string : ESCAPED_STRING
 
     COMMENT: /(#|\\/\\/)[^\\n]*/
+    TRAILING_COMMA: ","
 
     %import common.ESCAPED_STRING
     %import common.SIGNED_NUMBER
@@ -151,6 +154,15 @@ class JSONLibraryException(BaseException):
     library = 'json'
 
 
+def _remove_trailing_commas(tree):
+    if isinstance(tree, Tree):
+        tree.children = [
+            _remove_trailing_commas(ch) for ch in tree.children
+                if not (isinstance(ch, Token) and ch.type == 'TRAILING_COMMA')
+        ]
+    return tree
+
+
 def loads(text, *args, **kwargs):
     ''' Deserialize `text` (a `str` or `unicode` instance containing a JSON
     document with Python or JavaScript like comments) to a Python object.
@@ -165,7 +177,7 @@ def loads(text, *args, **kwargs):
         text = text.decode(detect_encoding(text), 'surrogatepass')
 
     try:
-        parsed = parser.parse(text)
+        parsed = _remove_trailing_commas(parser.parse(text))
         final_text = serializer.reconstruct(parsed)
     except lark.exceptions.UnexpectedCharacters:
         raise ValueError('Unable to parse text', text)

Feature request: Ignore trailing commas
A common workflow of mine is to comment/uncomment items in a JSON file. This fails if I comment out the last item in a list/dictionary because the new last item now has a trailing comma. Is there any appetite for allowing trailing commas? Would a PR that included this functionality get accepted?
diff --git a/commentjson/tests/test_commentjson.py b/commentjson/tests/test_commentjson.py
index feca95b..accb45b 100755
--- a/commentjson/tests/test_commentjson.py
+++ b/commentjson/tests/test_commentjson.py
@@ -20,7 +20,8 @@ class TestCommentJson(unittest.TestCase):
                       'string_with_inline_comment',
                       'inline_has_special_characters',
                       'array_with_hash',
-                      'inline_last_quote')
+                      'inline_last_quote',
+                      'trailing_comma')
 
         for file_ in self.files:
             fpath = os.path.join(self.path, file_)
diff --git a/commentjson/tests/trailing_comma-commented.json b/commentjson/tests/trailing_comma-commented.json
new file mode 100755
index 0000000..1e862da
--- /dev/null
+++ b/commentjson/tests/trailing_comma-commented.json
@@ -0,0 +1,15 @@
+{
+    "a": 1,
+    "c": {
+        # d is cool
+        "d": "4.3",
+        // e is cool
+        "e": {
+            "1": "1 # testing", # test comment
+            "2": "2", # some other stupid comment
+            "2.2": "2", // some other stupid comment
+            "3": "3",
+        },
+    },
+    "b": 2, # b inline comment
+}
diff --git a/commentjson/tests/trailing_comma-uncommented.json b/commentjson/tests/trailing_comma-uncommented.json
new file mode 100755
index 0000000..21b512b
--- /dev/null
+++ b/commentjson/tests/trailing_comma-uncommented.json
@@ -0,0 +1,13 @@
+{
+    "a": 1,
+    "c": {
+        "d": "4.3",
+        "e": {
+            "1": "1 # testing",
+            "2": "2",
+            "2.2": "2",
+            "3": "3"
+        }
+    },
+    "b": 2
+}

pip install -e .
parse_log_pytest
pytest
six pytest
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///croot/attrs_1668696182826/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
-e git+https://github.com/vaidik/commentjson.git@f720d41ee1ef398a72d3ba8cc7a2951d4fe02a17#egg=commentjson
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
lark-parser==0.7.8
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pytest==7.1.2
six==1.17.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
zipp @ file:///croot/zipp_1672387121353/work

name: commentjson
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py37h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - lark-parser==0.7.8
      - six==1.17.0
prefix: /opt/conda/envs/commentjson

commentjson/tests/test_commentjson.py::TestCommentJson::test_load commentjson/tests/test_commentjson.py::TestCommentJson::test_loads
commentjson/tests/test_commentjson.py::TestCommentJson::test_dump commentjson/tests/test_commentjson.py::TestCommentJson::test_dump_throws_exception commentjson/tests/test_commentjson.py::TestCommentJson::test_dump_with_kwargs commentjson/tests/test_commentjson.py::TestCommentJson::test_dumping_parsing_simple_string commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps_throws_exception commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps_with_kwargs commentjson/tests/test_commentjson.py::TestCommentJson::test_load_throws_exception commentjson/tests/test_commentjson.py::TestCommentJson::test_load_with_kwargs commentjson/tests/test_commentjson.py::TestCommentJson::test_loads_throws_exception commentjson/tests/test_commentjson.py::TestCommentJson::test_loads_with_kwargs
commentjson/commentjson.py
commentjson/commentjson.py