Convert Document
Premium · 5 creditsConvert documents between formats — Markdown, HTML, LaTeX, PDF, DOCX, EPUB, and more. Powered by Pandoc.
Supported Formats
Section titled “Supported Formats”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,epub,odt) are returned as a presigned download URL.
Route 1 — Multipart Upload
Section titled “Route 1 — Multipart Upload”POST /api/convert-document — max 50 MB
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | Document file to convert |
options | JSON string | No | Conversion options as a JSON-encoded string |
Route 2 — JSON
Section titled “Route 2 — JSON”POST /api/convert-document/json — max 50 MB
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | Yes | — | Document content. Plain text for text formats, base64 for binary |
from | string | Yes | — | Input format |
to | string | Yes | — | Output format |
content_encoding | string | No | text | text or base64 — use base64 for binary content |
options.toc | boolean | No | false | Include table of contents |
options.standalone | boolean | No | false | Produce standalone document with headers |
options.number_sections | boolean | No | false | Number sections |
options.highlight_style | string | No | — | Code syntax highlighting style |
options.extract_media | boolean | No | false | Extract and upload embedded media |
options.structured_metadata | boolean | No | false | Extract structured metadata |
files | object | No | — | Embedded assets as {"path": "base64_content"} |
Response
Section titled “Response”| Field | Type | Description |
|---|---|---|
output | string | Converted content (text formats) |
output_url | string | Presigned download URL (binary formats) |
expires_at | string | URL expiry timestamp |
format | string | Output format |
size_bytes | integer | Output size in bytes |
media | array | Extracted media — each has path and url |
Manuscript Mode
Section titled “Manuscript Mode”Set options.mode to manuscript for academic document processing. Returns dual output in JATS XML and Markdown, plus structured metadata.
Additional request fields:
| Field | Type | Description |
|---|---|---|
options.mode | string | Set to manuscript |
options.output_formats | array | Output formats to produce |
Additional response fields:
| Field | Type | Description |
|---|---|---|
jats | string | JATS XML output |
markdown | string | Markdown output |
metadata | object | Structured document metadata |
Examples
Section titled “Examples”Markdown to HTML (JSON)
Section titled “Markdown to HTML (JSON)”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}DOCX to PDF (multipart)
Section titled “DOCX to PDF (multipart)”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}With table of contents
Section titled “With table of contents”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}Errors
Section titled “Errors”- 503 — Storage unavailable for binary output formats.
See Errors for the standard error shape.