NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #672 most downloaded on PyPI
A package to repair broken json strings
Last release 9 days ago
22 Sep 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 59 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
3 years old
180 releases · first in 2023
One column per quarter.
# Fixed - Remove garbage output
Support multiple objects in one string such as here you go {"key":"value"} and also [1,2,3] will return an array of all the valid objects found [{"key
here you go {"key":"value"} and also [1,2,3] will return an array of all the valid objects found [{"key":"value"},[1,2,3]]This release is sponsored by @AvantiB. Thank you very much for your donation!
This library is free for everyone and it's maintained and developed as a side project so, if you find this library useful for your work, consider offering me a beer via this link: https://github.com/sponsors/mangiucugna
Fix #50, if a primitive type (string, bool, number) is outside of an object or array and the json is invalid, ignore those because it's impossible to
Partially address #49, stray quotes followed by a comma are supported if it's at the end of an object
Fix #47, a stupid regression due to missing tests in the last refactor was messing up a complex json. In particular how the word "false"was managed in
Fix #46, add the support for a new edge case: in case we have non escaped quotes in an object value and a comma is present, don't automatically trunca
There was an edge case in which a stray comment inside an object that looked like a boolean would be repaired as a key
Fix #44, a better way to deal with escaping sequences in python and that is hopefully the last time I fix this.
PR #43, sometimes LLMs will be "lazy" and add an ellipsis in arrays to mean "etc.." like [1, 2, ..., 10] or [1, 2, 3, ...]. Previously the ellipsis wa
[1, 2, ..., 10] or [1, 2, 3, ...]. Previously the ellipsis was converted to string as it was not a targeted use case, now it is ignored. Thanks to @mlxyz for pushing this change.This release is sponsored by @haydenth. Thank you very much for your donation!
This library is free for everyone and it's maintained and developed as a side project so, if you find this library useful for your work, consider offering me a beer via this link: https://github.com/sponsors/mangiucugna
Fix #42, add support for currency-like numbers.
Nothing published for this version
Fix #34, sometimes llms spit weird thoughts and comments in the middle of objects, improve how we handle that.
Fix #40, in some cases a \ would send the library in an infinite loop.
Fix #39, a regression after the large refactor of the string function (done to support new use cases) introduced a bug in which the library would fail
Improve load() to avoid loading the file in memory but stream it byte by byte. This brings the method on parity with json.load() and allows large stre
load() to avoid loading the file in memory but stream it byte by byte. This brings the method on parity with json.load() and allows large stream of data to be processedFix #38, the new functions load() and from_file() were not properly exported but pointed to loads().
load() and from_file() were not properly exported but pointed to loads().Fix #37, the parser was wrongly allowing an object key to be any type but that should be only string type. This is fixed now.
string type. This is fixed now.Fix #36, a simple case of a missing comma in a simple object wasn't handled correctly, still a regression from 0.14.0.
Better handling of stray characters. Before this version, stray characters at the beginning of a valid json ( e.g. string { 'a': 'b'} ) would not be i
string { 'a': 'b'} ) would not be ignored and the json produced would be invalid.Fixed #33, the feature released in 0.14.0 had a number of unexpected side effects. This should provide a more general and stable fix.
Sorry for any inconvenience, please keep sending examples as this specific feature is really at the core of a bunch of different failure modes
A more stable and general fix to the bug fixed in 0.15.5
Fix #32, an empty object value ("") would cause a crash under certain conditions.
Fixed #29, numbers like .25 where not considered numbers. Thanks to @paulb-instacart for reporting and pushing the PR!
Fixed #27, handle fractions such as 1/3 as string "1/3". Thanks to @paulb-instacart for reporting the issue and providing a PR to fix!
Ensure that all functions passthrough optional parameters to repair_json()
Adding a logging capability to understand what has been repaired. This was a feature request that was bubbling up in the issues, probably still incomp
logging=True to repair_json() and it will return a tuple instead of just the corrected jsonFixed #26 by adding a more general way to handle special cases with html tags and markdown in which the LLM uses the wrong quotation mark. Thanks to @
Fixed #24, fixed how the library handles the change of context when objects and arrays are mixed. Before this case would cause a crash.
New function load(fd) that is a drop in replacement for json.load()
load(fd) that is a drop in replacement for json.load()from_file(string_file_path) that makes it easier to write scripts to batch process json filesFix #23, if a dangling quotation mark followed a number or a boolean it would break the json string.
Generalize the double quotation fix
Fix a corner case in case the double quotation marks aren't repeated
Fix #20, support double quotation marks as string delimiters.
Fixed a bug, removing a character needs the counter to be decreased by 1 or the parser will eat the next character. Updated Unit Tests to check for th
Fixed #19, trailing backslashes cause json.loads() to throw an exception. Removing those unless are a valid escaping sequence.
Fixed #17, the library was not dealing with escaped quotes properly. Updated code, documentation and tests to deal with that corner case
Support for slanted double quotes “ ”
PR #16. Support for "number-like" strings such as number ranges or IP addresses, those will be interpreted as string. Thanks to @tmcdonnell87 for his
Fixes #15, a nasty corner case crashed the library.
A slightly more general solution to the code markdown issue solved in 0.7.0. From now on the library won't throw an exception anymore in case of garba
Fixes #13. Sometimes json blocks are returned as markdown codeblocks, remove the backticks before processing the json.
Small changes in code led to quite significant improvements in performance, releasing this patch version for anyone that cares about performance since
Fixed a couple of corner cases that shouldn't have affected anybody but is good to have them covered. Also improved readability.
Feature request #12. Added support for broken markdown links with unquoted quotes like { "content": "[LINK]("link")" }
{ "content": "[LINK]("link")" }Fixed issue #11, an empty key in an object would cause the library to go into an infinite loop.
Feature request #10. Small LLMs (like Mistral-7B) play fast and loose with quotes in strings so you can get single quoted strings (that is not JSON st
Please note that something like 'string" will be fixed as "string\"" because otherwise the string "won't" will be broken.
Fixes in previous releases had a negative performance impact, this release optimizes the code further to go back to previous performance benchmarks
Fixed #9, a corner case caused an infinite loop.
10% faster by removing some calls to get_char_at that could have been avoided
get_char_at that could have been avoidedFixed #8, a corner case caused an infinite loop.
Now it's 20% faster! After running through the profiler I found a few ways to improve the code and the most called methods. Updated the README to give
New option skip_json_loads' to skip the costly json.loads() call in repair_json`. See discussion in https://github.com/laiyer-ai/llm-guard/issues/44
skip_json_loads' to skip the costly json.loads()call inrepair_json`. See discussion in https://github.com/laiyer-ai/llm-guard/issues/44{ "key": "value", "key2": } wouldn't get repaired, this is fixed nowFixes #7. There are cases in which Llama will add some commentary in between key-values in an object. e.g. {"value_1": true, COMMENT "value_2": "data"
New exported method loads() that behave like json.loads()
loads() that behave like json.loads()Fix #5, Python 3.7 was always meant to be supported but the syntax := was used and that was not supported by 3.7. That was removed in this version.
:= was used and that was not supported by 3.7. That was removed in this version.Fix #4, This releases fixes an annoying issue in which python code created by gpt is unhelpfully broken by json_repair
Issue #1 fixed by @brettrp, better handling of whitespaces. Before this version only single spaces were handled properly
Fixed a bug. Sometimes when commas are present in valid JSON it will break. Skip parser completely if the JSON is valid.
Fixed a bug. Sometimes when commas are present in valid JSON it will break. Skip parser completely if the JSON is valid.
Added another case that is fixable, updated tests to reflect that
Added another case that is fixable, updated tests to reflect that
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →