POST
/api/v1/convert/json-to-pdfJSON to PDF
Transform JSON data into structured PDF reports with automatic table formatting, nested object support, color-coded status values, and customizable styling. Pass an array for tabular output or an object for key-value rendering.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| json_data | string | object | array | Yes | - | JSON data to render. Accepts a JSON string, object, or array. |
| page_size | string | No | A4 | Page size: A4, LETTER, LEGAL, TABLOID, A3, A5, etc. |
| orientation | string | No | portrait | Page orientation: portrait or landscape. |
| margin_top | int | No | 72 | Top margin in points. Range: 0-144. |
| margin_bottom | int | No | 72 | Bottom margin in points. Range: 0-144. |
| margin_left | int | No | 72 | Left margin in points. Range: 0-144. |
| margin_right | int | No | 72 | Right margin in points. Range: 0-144. |
| font_size | int | No | 10 | Body font size in points. Range: 8-16. |
| header_font_size | int | No | 12 | Header font size in points. Range: 10-18. |
| table_style | string | No | default | Table styling: default, minimal, or modern. |
| max_nesting_depth | int | No | 2 | Maximum nesting depth for nested objects. Range: 1-5. |
| title | string | No | null | Document title displayed at the top of the PDF. |
| title_font_size | int | No | 20 | Title font size in points. Range: 12-36. |
| subtitle | string | No | null | Subtitle displayed below the title. |
| header_bg_color | string | No | navy | Background color for table headers (CSS color or hex). |
| alternate_row_color | string | No | null | Background color for alternating rows (CSS color or hex). |
| border_color | string | No | #e0e0e0 | Table border color (hex). |
| status_colors | bool | No | true | Automatically color-code status values (e.g., active=green, pending=orange). |
| show_page_numbers | bool | No | false | Show page numbers in the footer. |
| footer_text | string | No | null | Custom footer text on each page. |
Code Examples
cURL
curl -X POST "https://app.alternapdf.com/api/v1/convert/json-to-pdf" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"json_data": [
{"name": "Alice Johnson", "role": "Engineer", "status": "active"},
{"name": "Bob Smith", "role": "Designer", "status": "active"},
{"name": "Carol White", "role": "PM", "status": "on_leave"}
],
"title": "Team Directory",
"subtitle": "Q1 2026",
"table_style": "modern",
"header_bg_color": "#1e3a5f",
"alternate_row_color": "#f8fafc",
"show_page_numbers": true,
"status_colors": true
}' \
--output team-report.pdfPython
import requests
response = requests.post(
"https://app.alternapdf.com/api/v1/convert/json-to-pdf",
headers={"X-API-Key": "YOUR_API_KEY"},
json={
"json_data": [
{"name": "Alice Johnson", "role": "Engineer", "status": "active"},
{"name": "Bob Smith", "role": "Designer", "status": "active"},
{"name": "Carol White", "role": "PM", "status": "on_leave"}
],
"title": "Team Directory",
"subtitle": "Q1 2026",
"table_style": "modern",
"header_bg_color": "#1e3a5f",
"alternate_row_color": "#f8fafc",
"show_page_numbers": True,
"status_colors": True
}
)
with open("team-report.pdf", "wb") as f:
f.write(response.content)JavaScript
const response = await fetch("https://app.alternapdf.com/api/v1/convert/json-to-pdf", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
json_data: [
{ name: "Alice Johnson", role: "Engineer", status: "active" },
{ name: "Bob Smith", role: "Designer", status: "active" },
{ name: "Carol White", role: "PM", status: "on_leave" },
],
title: "Team Directory",
subtitle: "Q1 2026",
table_style: "modern",
header_bg_color: "#1e3a5f",
show_page_numbers: true,
}),
});
fs.writeFileSync("team-report.pdf", Buffer.from(await response.arrayBuffer()));Response
Returns the PDF as a binary download with Content-Type: application/pdf.
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="converted.pdf"
X-Credits-Used: 1
X-Credits-Remaining: 4999
<binary PDF data>