POST/api/v1/convert/json-to-pdf

JSON 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

NameTypeRequiredDefaultDescription
json_datastring | object | arrayYes-JSON data to render. Accepts a JSON string, object, or array.
page_sizestringNoA4Page size: A4, LETTER, LEGAL, TABLOID, A3, A5, etc.
orientationstringNoportraitPage orientation: portrait or landscape.
margin_topintNo72Top margin in points. Range: 0-144.
margin_bottomintNo72Bottom margin in points. Range: 0-144.
margin_leftintNo72Left margin in points. Range: 0-144.
margin_rightintNo72Right margin in points. Range: 0-144.
font_sizeintNo10Body font size in points. Range: 8-16.
header_font_sizeintNo12Header font size in points. Range: 10-18.
table_stylestringNodefaultTable styling: default, minimal, or modern.
max_nesting_depthintNo2Maximum nesting depth for nested objects. Range: 1-5.
titlestringNonullDocument title displayed at the top of the PDF.
title_font_sizeintNo20Title font size in points. Range: 12-36.
subtitlestringNonullSubtitle displayed below the title.
header_bg_colorstringNonavyBackground color for table headers (CSS color or hex).
alternate_row_colorstringNonullBackground color for alternating rows (CSS color or hex).
border_colorstringNo#e0e0e0Table border color (hex).
status_colorsboolNotrueAutomatically color-code status values (e.g., active=green, pending=orange).
show_page_numbersboolNofalseShow page numbers in the footer.
footer_textstringNonullCustom 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.pdf
Python
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>