# Overview
Extracting JSON from real-world text can be challenging—especially when data is loosely formatted by humans or generated by large language models. Standard JSON parsers often fail or discard useful content when data is incomplete, contains extraneous text, or has minor formatting errors.
# About This Library
This library is designed to robustly extract JSON data from messy input. Whether the JSON snippet is embedded in surrounding text, has missing commas or braces, or contains other common human or machine errors, this tool strives to recover as much usable data as possible. It provides:
Resilient Extraction: Parses and extracts whatever JSON it can from noisy or partially malformed input.
Minimal Failures: It only fails when the input contains multiple independent JSON structures, making it highly tolerant in most real-world scenarios.
Failsafe Design: Built to maximize data recovery without being tripped up by small mistakes or unexpected formatting.
# Use Cases
Recovering JSON generated by LLMs or manual inputs with imperfect structure.
Parsing logs, transcripts, or text streams where valid JSON objects are surrounded by arbitrary text.
Extracting data from sources where strict JSON compliance cannot be guaranteed.
# Why Use This Library?
If traditional JSON parsers stop at the first mistake, this library aims to "make the best of what you have"—enabling you to keep moving forward with whatever data can be extracted. Perfect for developers and data wranglers who value resilience and flexibility in their text processing pipelines.
# Tests results
```
running 21 tests
test fuzzy_json_tests::test_builder_pattern ... ok
test fuzzy_json_tests::test_basic_parsing ... ok
test fuzzy_json_tests::test_code_block_markers ... ok
test fuzzy_json_tests::test_single_quotes ... ok
test fuzzy_json_tests::test_trailing_comma ... ok
test fuzzy_json_tests::test_mixed_quotes ... ok
test fuzzy_json_tests::test_truncated_after_colon ... ok
test fuzzy_json_tests::test_truncated_array ... ok
test fuzzy_json_tests::test_truncated_object ... ok
test fuzzy_json_tests::test_truncated_array_with_trailing_comma ... ok
test fuzzy_json_tests::test_mixed_truncation_scenarios ... ok
test fuzzy_json_tests::test_truncated_incomplete_property ... ok
test fuzzy_json_tests::test_truncated_string ... ok
test fuzzy_json_tests::test_truncated_with_complete_str_value_at_end ... ok
test fuzzy_json_tests::test_truncated_with_incomplete_str_value_at_end ... ok
test fuzzy_json_tests::test_truncated_with_incomplete_number_property_at_end ... ok
test fuzzy_json_tests::test_truncated_with_code_blocks ... ok
test fuzzy_json_tests::test_truncated_nested ... ok
test fuzzy_json_tests::test_json_locked_in_json_code_formating ... ok
test fuzzy_json_tests::test_json_having_arbitrary_text_in_beginning ... ok
test fuzzy_json_tests::test_json_having_arbitrary_text_at_the_end ... ok
test result: ok. 21 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.13s
```