JSON Repair API¶
Overview¶
Repairs common JSON syntax problems, including comments, single-quoted strings, unquoted property names, trailing commas, and Python-style True, False, and None values.
Endpoint¶
POST https://api.apidatatools.com/json-repair-api
Authentication¶
Include your API key in the x-api-key header.
Input modes¶
| Mode | Behavior |
|---|---|
body | Sends JSON-like text directly and repairs it synchronously. This is the default. |
url | Queues a public URL for asynchronous processing. |
file | Queues a previously uploaded file for asynchronous processing. |
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | — | Authenticates the request. |
x-source-type | String | No | body; body, url, file | Selects the input mode. |
Accepted file extensions¶
.txt, .json, and .log.
Request body¶
Body mode¶
Send JSON-like text directly; do not wrap it in another JSON object.
URL mode¶
{"url":"https://example.com/input.json"}
The URL must be public HTTP/HTTPS, reachable, within your plan limit, and end in an accepted extension.
File mode¶
{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}
Use the exact uploaded-object key, not its download URL.
cURL examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/json-repair-api' \\
-H 'x-api-key: YOUR_API_KEY' \\
--data-raw "{name:'Ada',active:True,}"
URL mode¶
curl --request POST \
--url https://api.apidatatools.com/json-repair-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: url' \
--header 'Content-Type: application/json' \
--data '{"url":"https://example.com/input.json"}'
File mode¶
curl --request POST \
--url https://api.apidatatools.com/json-repair-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: file' \
--header 'Content-Type: application/json' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
HTTP 200:
{"request_id":"REQUEST_ID","status":"success","file":"https://downloads.apidatatools.com/OUTPUT_FILE","preview":"{\n \"name\": \"Ada\",\n \"active\": true\n}"}
Asynchronous submission¶
URL and file modes return HTTP 202:
{"status":"accepted","job_id":"JOB_ID","status_url":"https://api.apidatatools.com/jobs/JOB_ID","request_id":"REQUEST_ID"}
Async job status¶
Poll with the same API key:
curl --request GET \
--url https://api.apidatatools.com/jobs/JOB_ID \
--header 'x-api-key: YOUR_API_KEY'
A queued or processing response includes message and retry_after:
{"request_id":"REQUEST_ID","job_id":"JOB_ID","status":"queued","created_at":1730000000,"updated_at":1730000000,"message":"Your job is being processed.","retry_after":2}
On success, status is success and result contains status, the temporary file URL, and preview. On failure, status is failed and error contains code, message, and details.
Error response¶
{"status":"error","error":"ERROR_CODE","request_id":"REQUEST_ID","details":{"message":"Description of the error."}}
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, JSON_REPAIR_FAILED, JSON_TOO_DEEP, INVALID_JSON_ENCODING |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, AUTH_ERROR, INTERNAL_ERROR |
Async submission can also return INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION, FILE_TOO_LARGE, CONFIG_ERROR, or PLAN_CONFIG_ERROR. Processing failures appear through job status and can include INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, or a repair error.
Notes¶
- Repair is conservative; input that cannot be safely repaired is rejected.
- JSON nesting is limited to 512 levels.
- Body mode is synchronous; URL and file modes are asynchronous.
- Honor
retry_afterwhile polling. Job-status errors includeINVALID_JOB_ID,JOB_NOT_FOUND,FORBIDDEN, andDDB_ERROR. - Body/file limits, quotas, rate limits, and retention depend on your plan. See tool limits.
- Output URLs are temporary; download results before retention expires.