Skip to main content

Convert Markdown

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

Submit a conversion

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)

With conversion options

Customize 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"
}
}
}

See Conversion Options for all format-specific settings.

Poll conversion status

# wait_until_complete handles polling automatically
conversion.wait_until_complete(timeout=30)
print(conversion.conversion_status())

Response while processing:

{
"status": "completed",
"conversion_status": {
"docx": { "status": "processing" },
"tex.zip": { "status": "processing" }
}
}

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 by appending the 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

Available formats

md, docx, tex.zip, html, pdf, latex.pdf, pptx, mmd.zip, md.zip, html.zip

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.

Next steps