# Repair Broken JSON from LLMs - Offline JSON Fixer (`tidybytetools/json-repair`) Actor

Repair broken or incomplete JSON from language models. Offline, no API key. $0.001 per document. Already-valid JSON is reported honestly. Failed empty input is free. Works from Apify MCP and the API.

- **URL**: https://apify.com/tidybytetools/json-repair.md
- **Developed by:** [Tidy Byte Tools](https://apify.com/tidybytetools) (community)
- **Categories:** Developer tools, AI, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 document repaireds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Repair Broken JSON from LLMs

Fix broken or incomplete JSON, including output from language models. Runs offline. No API key.

**Repair JSON. $0.001 per document. Already-valid JSON is reported honestly. Empty input is free. Works from Apify MCP and the API.**

Try it free: Apify gives every account $5 of free credit each month (no card), which covers about 5,000 one-document runs of this tool.

Also searched as: ES: reparar JSON roto, arreglar JSON de IA / PT: reparar JSON quebrado, corrigir JSON de IA / DE: defektes JSON reparieren / FR: réparer un JSON cassé, corriger un JSON d'IA / JA: 壊れたJSONを修復 / ZH: 修复损坏的JSON、修复AI生成的JSON

### Example (real run, Nov 17, 2026)

Input (not valid JSON: unquoted keys, single quotes, a trailing comma):

```json
{ "jsonText": "{name: 'Ada', ok: true, trailing: 'comma',}" }
```

Output (one dataset item):

```json
{
  "type": "document",
  "source": "pasted.json",
  "wasValid": false,
  "repaired": true,
  "value": { "name": "Ada", "ok": true, "trailing": "comma" }
}
```

Also searched as: ES: reparar JSON, JSON roto / PT: reparar JSON, JSON quebrado / DE: JSON reparieren / FR: réparer un JSON cassé / JA: 壊れたJSONを修復

### Example

Input:

```json
{
  "jsonText": "{name: 'Ada', ok: true, trailing: 'comma',}"
}
```

That input is not valid JSON (unquoted keys, single quotes, trailing comma). Output from an actual run:

```json
{
  "name": "Ada",
  "ok": true,
  "trailing": "comma"
}
```

Already-valid JSON is left alone and reported honestly as `wasValid: true`.

### Free local version

A free local CLI and MCP server is on [GitHub](https://github.com/tidybytetools/json-repair-lite). It runs on your computer and does not fetch file links.

### Input

- Paste one JSON value, or several JSON Lines
- Or add links to .json or .jsonl files
- Turn on "Treat input as JSON Lines" to force one document per line

### Output

One dataset row per document, with the repaired value, whether it was already valid, and a downloadable JSON file in the key-value store.

### Price

You pay **$0.001** per document we save, including JSON that was already valid. Empty or unreadable input is free. There is no start fee from us. Apify adds its normal small platform cost.

### Honest limits

- This is a deterministic repair step, not a language model. It can close missing brackets and fix common syntax issues. It cannot invent the data you meant to write.
- Some text cannot be repaired. Those rows are errors, and they are free.
- We do not fetch URLs that are *inside* the JSON. File links are only the files you ask us to read.

### FAQ

**Works from Apify MCP?** Yes. Search for "json repair" or "fix broken json".
**Do you call an AI model?** No. The repair runs offline.

# Actor input Schema

## `jsonText` (type: `string`):

Paste one JSON value, or several JSON Lines (one value per line).

## `fileUrls` (type: `array`):

Links to .json or .jsonl files to repair.

## `jsonLines` (type: `boolean`):

If true, each non-empty line is a separate document. If false, we first try the whole text as one JSON value, then fall back to JSON Lines if that fails and there are several lines.

## Actor input object example

```json
{
  "jsonText": "{name: 'Ada', ok: true, trailing: 'comma',}",
  "jsonLines": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "jsonText": "{name: 'Ada', ok: true, trailing: 'comma',}"
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidybytetools/json-repair").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "jsonText": "{name: 'Ada', ok: true, trailing: 'comma',}" }

# Run the Actor and wait for it to finish
run = client.actor("tidybytetools/json-repair").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "jsonText": "{name: '\''Ada'\'', ok: true, trailing: '\''comma'\'',}"
}' |
apify call tidybytetools/json-repair --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tidybytetools/json-repair"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/MMX9Bg3VM9LP8Jhyx/builds/F3gIR9c5QMHMhyOgM/openapi.json
