Skip to content

JSON Minify API Documentation

Overview

The JSON Minify API validates and minifies JSON input by removing unnecessary whitespace while preserving the data structure.
It supports three input modes: - Body Mode (Synchronous) – Direct JSON text in the request body. - URL Mode (Asynchronous) – Remote JSON file accessible via a public HTTP/HTTPS URL. - File Mode (Asynchronous) – JSON file previously uploaded to the platform.

The API returns a minified JSON file and a short preview of the output.
For asynchronous operations, a job ID is returned to check processing status later.


Endpoint (POST)

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

Headers

Header Description Required Example
Content-Type MIME type of the request body Yes application/json
x-api-key Your API key for authentication Yes abcd1234xyz
x-source-type Input mode: body, url, or file Optional (default: body) url

Accepted File Extensions

Mode Allowed Extensions
URL / File .txt, .json, .log

Input Example (Body Mode)

{
  "name": "John",
  "age": 30,
  "city": "New York"
}

Input Example (URL Mode)

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

Input Example (File Mode)

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

Example Request

Synchronous (Body Input)

curl -X POST "https://api.apidatatools.com/json-minify-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-source-type: body" \
  -d '{"name": "John", "age": 30, "city": "New York"}'

Asynchronous (Remote File URL)

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

Asynchronous (Input File)

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

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b2f1e4d3-9a7c-4c2b-8a7e-1f2a3b4c5d6e",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
  "preview": "{\"name\":\"John\",\"age\":30,\"city\":\"New York\"}"
}

Async Job Accepted

{
  "status": "accepted",
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "request_id": "b2f1e4d3-9a7c-4c2b-8a7e-1f2a3b4c5d6e"
}

Error Handling

Error Code HTTP Status Description Example
INVALID_JSON 400 The provided JSON is invalid or malformed. {"status":"error","error":"INVALID_JSON","details":{"message":"JSON validation failed.","line":2,"column":10}}
INVALID_URL 400 The provided URL is missing or invalid. {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}}
URL_UNREACHABLE 400 The remote URL could not be reached. {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}}
URL_NOT_OK 400 The remote URL did not return HTTP 200. {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}}
FILE_TOO_LARGE 413 The file exceeds the allowed size limit. {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}}
INVALID_FILE_EXTENSION 400 File extension not supported. {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Extension '.exe' is not allowed"}}
EMPTY_BODY 400 Request body is empty. {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}}
PAYLOAD_TOO_LARGE 413 Request body exceeds plan limit. {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds 5120KB limit for your plan."}}
INTERNAL_ERROR 500 Unexpected internal error occurred. {"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 status_url provided in the accepted response.

Endpoint

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

Example Status Response for Async

Queued / Processing

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status": "queued",
  "message": "Your job is being processed.",
  "retry_after": 2,
  "created_at": 1712345678,
  "updated_at": 1712345678
}

Successful

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "result": {
    "status": "success",
    "request_id": "b7f9e1c3-8d2a-4e6f-9a3c-0d8e7f2b9a1f",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
    "preview": "{\"name\":\"John\",\"age\":30,\"city\":\"New York\"}"
  }
}

Failed

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

Notes for Developers

  • The API supports body, url, and file input modes.
  • For asynchronous operations (url or file), a job ID is returned immediately with HTTP 202.
  • Use the Status API to poll job progress or retrieve results.
  • The output file is stored temporarily and accessible via a secure download URL.
  • Each response includes a unique request_id for traceability.
  • Ensure that the input file extension matches one of the allowed types (.txt, .json, .log).
  • For large files or remote sources, prefer asynchronous processing to avoid timeouts.