| Crates.io | anyrepair |
| lib.rs | anyrepair |
| version | 0.1.9 |
| created_at | 2025-10-23 18:36:35.988704+00 |
| updated_at | 2025-11-24 04:40:11.68737+00 |
| description | A comprehensive Rust crate for repairing LLM responses including JSON, YAML, XML, TOML, CSV, INI, and Markdown with advanced analytics and enterprise features |
| homepage | https://github.com/yingkitw/anyrepair |
| repository | https://github.com/yingkitw/anyrepair |
| max_upload_size | |
| id | 1897481 |
| size | 1,690,707 |
A Rust crate for repairing malformed LLM responses across multiple formats (JSON, YAML, Markdown, XML, TOML, CSV, INI, Diff).
[dependencies]
anyrepair = "0.1.5"
use anyrepair::repair;
// Auto-detect format and repair
let malformed = r#"{"name": "John", age: 30,}"#;
let repaired = repair(malformed)?;
println!("{}", repaired); // {"name": "John", "age": 30}
# Install
cargo install anyrepair
# Repair a file
anyrepair input.json
# Auto-detect format
anyrepair input.txt
🆕 Diff/Unified Diff Format Support
📊 Enterprise Features
📚 Documentation Improvements
⚡ Performance & Quality
See CHANGELOG.md for complete version history.
LLMs often generate malformed structured data. AnyRepair fixes common issues:
Key Features:
use anyrepair::repair;
// JSON
let json = repair(r#"{"key": value,}"#)?;
// YAML
let yaml = repair("name: John\nage: 30")?;
// Markdown
let markdown = repair("# Header\n[link](url")?;
use anyrepair::{JsonRepair, YamlRepairer, MarkdownRepairer};
// JSON (Python jsonrepair-compatible API)
let mut jr = JsonRepair::new();
let repaired = jr.jsonrepair(malformed_json)?;
// YAML
let mut yaml_repairer = YamlRepairer::new();
let repaired = yaml_repairer.repair(malformed_yaml)?;
// Markdown
let mut md_repairer = MarkdownRepairer::new();
let repaired = md_repairer.repair(malformed_markdown)?;
use anyrepair::StreamingRepair;
use std::fs::File;
use std::io::BufReader;
let input = BufReader::new(File::open("large_file.json")?);
let mut output = File::create("repaired.json")?;
let processor = StreamingRepair::with_buffer_size(8192);
processor.process(input, &mut output, "json")?;
# Run MCP server for Claude
anyrepair-mcp
# Configure in claude_desktop_config.json:
# {
# "mcpServers": {
# "anyrepair": {
# "command": "anyrepair-mcp"
# }
# }
# }
See MCP_SERVER.md for details.
| Format | Common Issues Fixed |
|---|---|
| JSON | Missing quotes, trailing commas, malformed numbers, boolean/null values |
| YAML | Indentation, missing colons, list formatting, document separators |
| Markdown | Headers, code blocks, lists, tables, links, images |
| XML | Unclosed tags, malformed attributes, missing quotes, entity encoding |
| TOML | Missing quotes, malformed arrays, table headers, dates |
| CSV | Unquoted strings, malformed quotes, extra/missing commas |
| INI | Malformed sections, missing equals signs, unquoted values |
| Diff | Missing hunk headers, incorrect line prefixes, malformed ranges |
# Add custom repair rule
anyrepair rules add --id "fix_undefined" --format "json" \
--pattern "undefined" --replacement "null"
Extend functionality with custom repair strategies. See Plugin Development Guide.
See Enterprise Features for details.
See TEST_SUMMARY.md for details.
| Feature | AnyRepair | json-repair-rs | json5 |
|---|---|---|---|
| Multi-format | ✅ 8 formats | ❌ JSON only | ❌ JSON only |
| Auto-detection | ✅ | ❌ | ❌ |
| MCP integration | ✅ | ❌ | ❌ |
| Streaming | ✅ | ❌ | ❌ |
| Custom rules | ✅ | ❌ | ❌ |
See the examples/ directory for:
Apache-2.0