[](https://crates.io/crates/json-fix)
[](https://docs.rs/json-fix)
# π οΈ json-fix
**json-fix** is a blazing-fast, Rust-powered JSON repair library built for resilient data pipelines, GPT outputs, web scraping tools, and any system where malformed JSON sneaks in.
It detects and fixes broken JSON strings β from misescaped quotes to missing commas β using a curated sequence of regex-powered healing steps. Ideal for both CLI tools and backend services.
---
## π Features
- β
Fixes unescaped or invalid quote issues
- β
Repairs trailing commas, missing brackets, and embedded key-value bugs
- β
Pure Rust β no unsafe, no dependencies outside `fancy-regex`
- β
Supports logs for each fix step
- β
Battle-tested against AI-generated JSON errors
- β
Easily embeddable as a library or CLI tool
---
## π§ͺ Example
```rust
use json_fix::fix_json_syntax;
fn main() {
let broken = r#"{ "name": "Momo, "age": 3 }"#;
let result = fix_json_syntax(broken);
if result.fixed != broken {
println!("β
Fixed JSON:\n{}", result.fixed);
} else {
println!("β οΈ No changes made.");
}
}
```
---
## π Usage
### Install:
```bash
cargo add json-fix
```
### As a library:
```rust
let result = fix_json_syntax(broken);
```
### From CLI:
```bash
cargo run --example quick_fix
```
---
## π Benchmarks
Run:
```bash
cargo bench
```
---
## π Project Structure
- `src/lib.rs` β Public-facing API
- `src/fixer.rs` β Core fix logic (regex-powered)
- `examples/quick_fix.rs` β Minimal usage demo
- `tests/fixer.rs` β Real-world test case
- `benches/fix_benchmark.rs` β Criterion benchmarks
---
## βοΈ License
MIT β In shΔΚΎ AllΔh, may it be a source of barakah for those who use and improve it.