json-repairj

September 8, 2025 ยท View on GitHub

Maven Central Build

json-repairj

A java library to repair broken JSON strings, particularly useful for handling malformed JSON output from Large Language Models.

This is a porting of the Python library json_repair, written by Stefano Baccianella and published under the MIT license.

All credits go to the original author for the amazing work.

Setup

We will try to keep up to tags of the original project, just push/fire an issue if delay.

<dependency>
    <groupId>io.github.du00cs</groupId>
    <artifactId>json-repairj</artifactId>
    <version>${jsonRepairjVersion}</version>
</dependency>
implementation 'io.github.du00cs:json-repairj:${jsonRepairjVersion}'

Usage

import org.jsonrepair.JsonRepair;

String result = JsonRepair.repairJson(str);

// or more control (result = jackson node + warnings)
ParseResult result = JsonRepair.parseJson(str, skipLoads, streamStable);

Not Implemented

Some features are not implemented yet:

  • identity check in multiple json
  • read from file
  • stream stable not tested

License

MIT