Markdown to PDF

Convert Markdown content to professionally styled PDF documents.

POSThttps://api.morphopdf.com/v1/convert/markdown-to-pdf

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

Provide Markdown content using one of the following methods (mutually exclusive).

fileFileOptional

Markdown file (.md) uploaded via multipart/form-data.

urlstringOptional

Public URL pointing to a Markdown file.

markdownstringOptional

Raw Markdown string to convert to PDF.

Query Parameters

formatstringOptionalDefault: json

Response format. Use 'binary' to receive the PDF directly, or 'json' (default) to receive metadata with a download URL.

Professional Styling

Markdown is converted to HTML first, then rendered to PDF with professional styling including syntax highlighting for code blocks, proper typography, and clean layout.

Response

When using format=json (default):

successboolean

Indicates whether the operation completed successfully.

messagestring

Human-readable status message.

fileNamestring

Name of the generated PDF document.

downloadUrlstring

Presigned URL to download the file. Valid for 1 hour.

processingTimeMsnumber

Time taken to process the conversion in milliseconds.

conversionMethodstring

Conversion method used (e.g. 'marked-puppeteer').

Binary Response

Add ?format=binary to receive the PDF directly with these headers:

  • Content-Type: application/pdf
  • Content-Disposition: attachment; filename="document.pdf"

Error Responses

StatusCodeDescription
400INVALID_INPUTNo Markdown content provided (file, url, or markdown required)
401AUTHENTICATION_REQUIREDMissing or invalid API key
413FILE_TOO_LARGEFile exceeds maximum size limit
500PROCESSING_FAILEDInternal processing error
POST/v1/convert/markdown-to-pdf
curl -X POST "https://api.morphopdf.com/v1/convert/markdown-to-pdf?format=binary" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@README.md" \
  --output document.pdf
200OK
{
  "success": true,
  "message": "File processed successfully",
  "fileName": "document.pdf",
  "downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/document.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
  "processingTimeMs": 950,
  "conversionMethod": "marked-puppeteer"
}