Skip to main content

Convert Markdown

Convert Mathpix Markdown (MMD) text to other formats like DOCX, LaTeX, HTML, PDF, and PPTX.

info

See Conversion Formats for the full list with availability and descriptions.

Workflow

  1. Submit MMD text with desired formats — returns a conversion_id
  2. Poll status with GET /v3/converter/{conversion_id}
  3. Download results by appending the format extension: GET /v3/converter/{conversion_id}.docx, .tex.zip, etc.

Submit a conversion

Submit Mathpix Markdown text to the v3/converter endpoint:

from mpxpy.mathpix_client import MathpixClient
client = MathpixClient(app_id="APP_ID", app_key="APP_KEY")
conversion = client.conversion_new(
mmd="_full mmd text_",
convert_to_docx=True,
convert_to_tex_zip=True,
)
print(conversion.conversion_id)
Example response
{
"conversion_id": "2024_01_15_abc123def456"
}

Use the conversion_id to poll conversion status and download results.

With conversion options

Customize the v3/converter output with format-specific options:

{
"mmd": "_full mmd text_",
"formats": {"docx": true, "pdf": true},
"conversion_options": {
"docx": {
"font": "Times New Roman",
"fontSize": "28",
"orientation": "portrait"
},
"pdf": {
"fontSize": "14",
"text_color": "black",
"margin": "40"
}
}
}
Example response
{
"conversion_id": "2024_01_15_abc123def456"
}

See Conversion Options for all format-specific settings.

Poll conversion status

Poll GET v3/converter/{conversion_id} to check the status of each requested format:

# wait_until_complete handles polling automatically
conversion.wait_until_complete(timeout=30)
print(conversion.conversion_status())
Example response while processing
{
"status": "completed",
"conversion_status": {
"docx": { "status": "processing" },
"tex.zip": { "status": "processing" }
}
}
Example response when all formats are ready
{
"status": "completed",
"conversion_status": {
"docx": { "status": "completed" },
"tex.zip": { "status": "completed" }
}
}

Download results

Once a format's status is "completed", download from GET v3/converter/{conversion_id}.{ext} by appending the format extension to the conversion ID:

# Save to files
conversion.to_docx_file(path="result.docx")
conversion.to_tex_zip_file(path="result.tex.zip")
conversion.to_html_file(path="result.html")
# Or get content in memory
docx_bytes = conversion.to_docx_bytes() # bytes
md_text = conversion.to_md_text() # str

Next steps

  • v3/converter reference — Full request parameters, conversion options per format, and response schema
  • Process a PDF — PDFs can also request conversion formats automatically