Skip to content

Convert Document

Premium · 5 credits

Convert documents between formats — Markdown, HTML, LaTeX, PDF, DOCX, EPUB, and more. Powered by Pandoc.

Input: markdown, html, latex, rst, plain, docx, pdf, epub, odt

Output: markdown, html, latex, rst, plain, jats, docx, pdf, epub, odt

Text formats (markdown, html, latex, rst, plain, jats) are returned inline. Binary formats (docx, pdf, epub, odt) are returned as a presigned download URL.

POST /api/convert-document — max 50 MB

FieldTypeRequiredDescription
filefileYesDocument file to convert
optionsJSON stringNoConversion options as a JSON-encoded string

POST /api/convert-document/json — max 50 MB

FieldTypeRequiredDefaultDescription
contentstringYesDocument content. Plain text for text formats, base64 for binary
fromstringYesInput format
tostringYesOutput format
content_encodingstringNotexttext or base64 — use base64 for binary content
options.tocbooleanNofalseInclude table of contents
options.standalonebooleanNofalseProduce standalone document with headers
options.number_sectionsbooleanNofalseNumber sections
options.highlight_stylestringNoCode syntax highlighting style
options.extract_mediabooleanNofalseExtract and upload embedded media
options.structured_metadatabooleanNofalseExtract structured metadata
filesobjectNoEmbedded assets as {"path": "base64_content"}
FieldTypeDescription
outputstringConverted content (text formats)
output_urlstringPresigned download URL (binary formats)
expires_atstringURL expiry timestamp
formatstringOutput format
size_bytesintegerOutput size in bytes
mediaarrayExtracted media — each has path and url

Set options.mode to manuscript for academic document processing. Returns dual output in JATS XML and Markdown, plus structured metadata.

Additional request fields:

FieldTypeDescription
options.modestringSet to manuscript
options.output_formatsarrayOutput formats to produce

Additional response fields:

FieldTypeDescription
jatsstringJATS XML output
markdownstringMarkdown output
metadataobjectStructured document metadata
Terminal window
curl -X POST https://morso.dev/api/convert-document/json \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "# Hello\n\nThis is **Markdown**.", "from": "markdown", "to": "html"}'
{
"output": "<h1>Hello</h1>\n<p>This is <strong>Markdown</strong>.</p>",
"format": "html",
"size_bytes": 52
}
Terminal window
curl -X POST https://morso.dev/api/convert-document \
-H "Authorization: Bearer YOUR_API_KEY" \
-F 'options={"from":"docx","to":"pdf"}'
{
"output_url": "https://storage.morso.dev/conversions/abc123.pdf?token=xyz",
"expires_at": "2026-05-04T13:00:00Z",
"format": "pdf",
"size_bytes": 184320
}
Terminal window
curl -X POST https://morso.dev/api/convert-document/json \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "# Chapter 1\n\nIntro.\n\n## Section 1.1\n\nDetails.\n\n# Chapter 2\n\nMore content.",
"from": "markdown",
"to": "html",
"options": {
"toc": true,
"number_sections": true,
"standalone": true
}
}'
{
"output": "<!DOCTYPE html>\n<html>\n<body>\n<nav id=\"TOC\">...</nav>\n<h1>1 Chapter 1</h1>\n<p>Intro.</p>\n<h2>1.1 Section 1.1</h2>\n<p>Details.</p>\n<h1>2 Chapter 2</h1>\n<p>More content.</p>\n</body>\n</html>",
"format": "html",
"size_bytes": 287
}
  • 503 — Storage unavailable for binary output formats.

See Errors for the standard error shape.