Skip to content

JSON Validator API Documentation

Overview

The JSON Validator API validates and pretty-prints JSON data.
It accepts input via direct body, remote file URL, or uploaded file.
The API returns a formatted JSON file.

Base URL:
https://api.apidatatools.com/json-validator-api


Endpoint (POST)

POST https://api.apidatatools.com/json-validator-api


Headers

Header Description Required Example
Content-Type Must be application/json for body input Yes application/json
x-source-type Defines input mode: body, url, or file Optional (defaults to body) url
x-api-key Your API key for authentication Yes abcd1234xyz

Accepted File Extensions

This tool supports the following file extensions for URL or file mode: - .txt - .json - .log


Input Example (Body Mode)

{
  "name": "John",
  "age": 30,
  "skills": ["Python", "API", "AWS"]
}

Input Example (URL Mode)

{
  "url": "https://example.com/sample.json"
}

Input Example (File Mode)

{
  "file": "user_uploads/sample.json"
}

Example Request

Synchronous (Body Input)

curl -X POST "https://api.apidatatools.com/json-validator-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: body" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"name":"John","age":30,"skills":["Python","API","AWS"]}'

Asynchronous (Remote File URL)

curl -X POST "https://api.apidatatools.com/json-validator-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: url" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"url":"https://example.com/sample.json"}'

Asynchronous (Input File)

curl -X POST "https://api.apidatatools.com/json-validator-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: file" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"file":"user_uploads/sample.json"}'

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b7f9e1c3-8d2a-4e6f-9a3c-0d8e7f2b9a1f",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
  "preview": "{\n  \"name\": \"John\",\n  \"age\": 30,\n  \"skills\": [\n    \"Python\",\n    \"API\",\n    \"AWS\"\n  ]\n}"
}

Async Job Accepted

{
  "status": "accepted",
  "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "request_id": "b7f9e1c3-8d2a-4e6f-9a3c-0d8e7f2b9a1f"
}

Error Handling

Error Code HTTP Status Description Example
INVALID_JSON 400 JSON validation failed {"status":"error","error":"INVALID_JSON","details":{"message":"JSON validation failed.","line":2,"column":5}}
INVALID_BODY_ENCODING 400 Failed to decode base64 body {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}}
EMPTY_BODY 400 Request body is empty {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}}
PAYLOAD_TOO_LARGE 413 Body exceeds plan limit {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}}
INVALID_URL 400 Invalid or missing URL {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}}
URL_UNREACHABLE 400 URL cannot be reached {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}}
URL_NOT_OK 400 URL returned non-200 status {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}}
FILE_TOO_LARGE 413 File exceeds plan limit {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}}
INVALID_FILE_EXTENSION 400 Unsupported file extension {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Extension '.xml' is not allowed."}}
INVALID_FILE 400 Missing or invalid file path {"status":"error","error":"INVALID_FILE","details":{"message":"Missing or invalid 'file'."}}
FILE_UNAVAILABLE 400 File not accessible {"status":"error","error":"FILE_UNAVAILABLE","details":{"message":"Could not access file."}}
INTERNAL_ERROR 500 Unexpected server error {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}}

Async Job Status

To check the status of an asynchronous job, use the following endpoint:

GET https://api.apidatatools.com/jobs/{job_id}

Example Status Response for Async

Queued

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "queued",
  "message": "Your job is being processed.",
  "retry_after": 2
}

Success

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345689,
  "result": {
    "request_id": "b7f9e1c3-8d2a-4e6f-9a3c-0d8e7f2b9a1f",
    "status": "success",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
    "preview": "{\n  \"name\": \"John\",\n  \"age\": 30,\n  \"skills\": [\n    \"Python\",\n    \"API\",\n    \"AWS\"\n  ]\n}"
  }
}

Failed

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "failed",
  "error": {
    "code": "INVALID_JSON",
    "message": "JSON validation failed.",
    "details": {
      "line": 2,
      "column": 5
    }
  }
}

Notes for Developers

  • The API supports three modes: body, url, and file.
  • When using url or file mode, the operation is asynchronous and returns a job_id.
  • Use the Status API to track job progress and retrieve results.
  • The response always includes a request_id for traceability.
  • Output files are stored temporarily and accessible via the returned S3 URL.
  • For large files, prefer asynchronous processing via URL or file mode.