Free plan

Repair JSON

Fix a broken data file so programs can read it again
POST
/v1/data/repair-json

About this tool

JSON is a text format for data. If a comma, quote or bracket is wrong, programs refuse it. This tool repairs common problems, such as comments, extra or missing commas, single quotes, unquoted names, Python words like None and True, and a cut-off ending. It also removes a code fence around an AI answer. It lists every fix it made.
For example, you repair the output of an AI tool that produced almost-valid JSON.

How to use it

  1. Choose this tool.
  2. Paste the broken text, or add your file with Upload or drag and drop.
  3. Choose how the result should look, such as indented or on one line.
  4. Press Generate.
  5. Copy or download the repaired JSON and read the list of fixes.

What you get back

You get valid JSON and a list of what was fixed. Copy it or download it as a file.
GOOD TO KNOW
Text that is already valid JSON is only re-formatted. A word the reader cannot place is put in quotes (quotes=true) or refused. Counts as one conversion.
TEST IT LIVE

Try Repair JSON in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Data
Plan
Free
Method
POST
Endpoint
/v1/data/repair-json
Tool ID
data.repair-json
Authentication
API key
Accepts
Text and settings
Background jobs
Yes
Usage group
Data
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/data/repair-json" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'text={'\''a'\'': 1, b: None,}' \
  -F 'output=json' \
  -F 'indent=2'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.data.repairJson({
    "text": "{'a': 1, b: None,}",
    "output": "json",
    "indent": 2
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->data()->repairJson([
    'text' => '{\'a\': 1, b: None,}',
    'output' => 'json',
    'indent' => 2,
]);
echo $result->requestId;
FAQ

Frequently asked questions

Make broken JSON valid again: a model answer in a code fence, comments, trailing and missing commas, single quotes, unquoted keys, Python words (None, True), a cut-off ending, or several objects in a row. The answer lists every fix.

Repair JSON works from text and settings, so no file is needed. Every input is optional.

Repair JSON is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/data/repair-json with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.