Skip to content

JSON to HTML API Documentation

Overview

The JSON to HTML API converts a valid JSON input into a structured HTML table representation.
It supports three modes of operation: - Body Mode – Direct JSON input in the request body. - URL Mode – Remote JSON file accessible via HTTP/HTTPS. - File Mode – Previously uploaded JSON file stored in S3.

The API validates the JSON structure before conversion and returns an HTML file link for download or preview.


Endpoint (POST)

POST https://api.apidatatools.com/json-to-html-api

Headers

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

Accepted File Extensions

This tool supports the following file extensions for input:

.txt, .json, .log


Input Example (Body Mode)

{
  "name": "John Doe",
  "age": 30,
  "skills": ["Python", "HTML", "CSS"]
}

Input Example (URL Mode)

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

Input Example (File Mode)

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

Example Request

Synchronous (Body Input)

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

Asynchronous (Remote File URL)

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

Asynchronous (Input File)

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

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b7d8c2f1-9e3a-4a2b-9f2e-1f2c3e4d5a6b",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.html",
  "preview": "<div class=\"table-responsive\" style=\"word-break: break-all;\"><table id=\"jsonTable\" class=\"table table-striped\" width=\"100%\" style=\"word-break: break-all;\"><tr><td>...</td></tr></table></div>"
}

Async Job Accepted

{
  "status": "accepted",
  "job_id": "job_12345abcd",
  "status_url": "https://api.apidatatools.com/jobs/job_12345abcd",
  "request_id": "b7d8c2f1-9e3a-4a2b-9f2e-1f2c3e4d5a6b"
}

Error Handling

Error Code HTTP Status Description Example
INVALID_JSON 400 JSON validation or parsing failed {"status":"error","error":"INVALID_JSON","details":{"message":"JSON validation failed."}}
HTML_CONVERSION_FAILED 400 Failed to convert JSON to HTML {"status":"error","error":"HTML_CONVERSION_FAILED","details":{"message":"Conversion error"}}
INVALID_BODY_ENCODING 400 Body could not be base64-decoded {"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"}}
FILE_TOO_LARGE 413 File exceeds plan limit {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"File exceeds plan limit"}}
INVALID_URL 400 Invalid or missing URL {"status":"error","error":"INVALID_URL","details":{"message":"URL must be valid http/https"}}
URL_UNREACHABLE 400 Could not reach remote URL {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}}
URL_NOT_OK 400 Remote URL returned non-200 status {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404"}}
INVALID_FILE_EXTENSION 400 Unsupported file extension {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension"}}
FILE_UNAVAILABLE 400 File not found in S3 {"status":"error","error":"FILE_UNAVAILABLE","details":{"message":"Could not access file"}}
INVALID_SOURCE_TYPE 400 Source type must be url or file {"status":"error","error":"INVALID_SOURCE_TYPE","details":{"message":"Must be 'url' or 'file'"}}
INTERNAL_ERROR 500 Unexpected internal error {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}}

Async Job Status

To check the status of an asynchronous job (URL or File mode):

Endpoint

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

Example Status Response for Async

Queued

{
  "job_id": "job_12345abcd",
  "status": "queued",
  "created_at": 1712345678,
  "updated_at": 1712345678,
  "message": "Your job is being processed.",
  "retry_after": 2
}

Success

{
  "job_id": "job_12345abcd",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "result": {
    "request_id": "b7d8c2f1-9e3a-4a2b-9f2e-1f2c3e4d5a6b",
    "status": "success",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.html",
    "preview": "<div class=\"table-responsive\">...</div>"
  }
}

Failed

{
  "job_id": "job_12345abcd",
  "status": "failed",
  "created_at": 1712345678,
  "updated_at": 1712345680,
  "error": {
    "code": "INVALID_JSON",
    "message": "JSON validation failed.",
    "details": {
      "line": 2,
      "column": 5
    }
  }
}

Notes for Developers

  • The API automatically validates JSON before conversion.
  • For large files or remote URLs, use asynchronous mode (x-source-type: url or file).
  • Each response includes a unique request_id for tracking.
  • The preview field contains a truncated HTML snippet (up to 100 KB).
  • The full HTML file is accessible via the returned file URL.
  • Asynchronous jobs can be monitored using the Status API endpoint.
  • Ensure proper authentication headers are included in all requests.
  • Supported input extensions: .txt, .json, .log.
  • Output format: HTML (text/html content type).