Download the PHP package teariot/json-repair without Composer
On this page you can find all versions of the php package teariot/json-repair. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download teariot/json-repair
More information about teariot/json-repair
Files in teariot/json-repair
Download teariot/json-repair
More information about teariot/json-repair
Files in teariot/json-repair
Vendor teariot
Package json-repair
Short Description Repair broken, malformed, or non-standard JSON — fix quotes, commas, comments, Python constants, JSONP, NDJSON, HTML entities, and more
License MIT
Package json-repair
Short Description Repair broken, malformed, or non-standard JSON — fix quotes, commas, comments, Python constants, JSONP, NDJSON, HTML entities, and more
License MIT
Please rate this library. Is it a good library?
Informations about the package json-repair
teariot/json-repair
PHP 8.0+ library to repair broken, malformed, or non-standard JSON.
Handles real-world garbage: LLM responses with <think> blocks, truncated output, single quotes, trailing commas, comments, JSONP, Python constants, MongoDB types, HTML entities, and more.
Installation
Quick Start
Extract JSON from Text
Pull JSON out of LLM responses, log lines, or any surrounding text:
json\n{\"a\": 1}\n
Template: Fill Missing Keys
When LLM output is truncated or incomplete, apply a template to ensure all expected keys exist:
What It Fixes
| Problem | Input | Output |
|---|---|---|
| Unquoted keys | {name: "John"} |
{"name":"John"} |
| Single quotes | {'a': 'b'} |
{"a":"b"} |
| Smart/curly quotes | {"a": "b"} |
{"a":"b"} |
| Backtick quotes | {`a`: `b`} | {"a":"b"} |
|
| Trailing commas | {"a": 1,} |
{"a":1} |
| Leading commas | {,"a": 1} |
{"a":1} |
| Missing commas | {"a": 1 "b": 2} |
{"a":1,"b":2} |
| Missing colons | {"a" 1} |
{"a":1} |
| Missing brackets | {"a": 1 |
{"a":1} |
| Redundant brackets | {"a": 1}} |
{"a":1} |
| Block comments | {"a": 1 /* x */} |
{"a":1} |
| Line comments | {"a": 1 // x} |
{"a":1} |
| Hash comments | {"a": 1 # x} |
{"a":1} |
| JSONP | callback({"a": 1}); |
{"a":1} |
| Markdown fences | | {"a":1} |
|
| Python True/False/None | {a: True, b: None} |
{"a":true,"b":null} |
| JS undefined/NaN | undefined |
null |
| String concatenation | "a" + "b" |
"ab" |
| Ellipsis | [1, 2, ...] |
[1,2] |
| Leading zero numbers | 0123 |
"0123" |
| Truncated JSON | {"a": |
{"a":null} |
| NDJSON | {"a":1}\n{"b":2} |
[{"a":1},{"b":2}] |
| Regex literals | /test/gi |
"/test/gi" |
| MongoDB types | ObjectId("abc") |
"abc" |
| HTML entities | "a & b" |
"a & b" |
<think> blocks |
<think>...</think> {} |
{} |
| Log prefixes | [date] level: {} |
{} |
Full API
Static Facade
Helper Functions
Streaming
Process large JSON files without loading everything into memory:
Requirements
- PHP >= 8.0
- ext-json
- ext-mbstring
- ext-ctype
Testing
License
MIT
All versions of json-repair with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
ext-ctype Version *
ext-json Version *
ext-mbstring Version *
ext-ctype Version *
ext-json Version *
ext-mbstring Version *
The package teariot/json-repair contains the following files
Loading the files please wait ...