Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

mathconv

mathconv converts math formulas from MathML, the markup that web pages, e-books and journal articles use for mathematics, into LaTeX, the notation most people use to type mathematics, or into plain text. It is a Python package with its core written in Rust.

<math>
  <msqrt>
    <msup><mi>x</mi><mn>2</mn></msup>
    <mo>+</mo>
    <mn>1</mn>
  </msqrt>
</math>

becomes \sqrt{x^2 + 1} in LaTeX and sqrt(x^2 + 1) as text.

mathconv is made for converting formulas in bulk: preparing text for training language models, search indexing, accessibility tools, migrating documents, and any other work where formulas taken from web pages, articles or e-books need to become LaTeX.

  • One style: a formula gives the same LaTeX whichever tool wrote its MathML.
  • Renders: KaTeX and MathJax, the common web renderers, accept every output.
  • Fast: about 740,000 typical formulas a second through convert_batch, 830,000 in the Rust core, on one core of a GitHub-hosted runner (measured on 2026-12-03).
  • Nothing silently lost: broken markup is repaired, and anything left unconverted is kept as text and reported.

Installation

pip install --pre mathconv

mathconv needs Python 3.10 or later and has prebuilt wheels for Linux, macOS and Windows; --pre is needed while only pre-releases are published. mathconv is in early development: until 1.0, output and API can change between releases, so pin a version if you need reproducible output (changelog).

Usage

import mathconv

mathml = "<math><msqrt><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></msqrt></math>"
mathconv.convert(mathml)
# '\\sqrt{x^2 + 1}'
mathconv.convert(mathml, target="text")
# 'sqrt(x^2 + 1)'

Each call takes one formula, in presentation markup (how it looks), content markup (what it means) or a mix, as found in web pages and XML documents; finding the formulas in a page is up to the caller. A Converter keeps options, converts lists and returns details:

converter = mathconv.Converter(delimiters="dollar")  # wrap each formula in $ signs
converter.convert_batch(["<math><mi>a</mi></math>", '<math display="block"><mi>b</mi></math>'])
# ['$a$', '$$b$$']
result = converter.result("<math><mi>E</mi><mo>=</mo><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup></math>")
result.output, result.fallbacks  # ('$E = mc^2$', []): fallbacks lists anything left unconverted

Quality

The mathconv corpus holds about 235,000 public MathML formulas from openly licensed articles, Wikipedia, textbooks and common converters (how this is measured).

From To Formulas Fully converted Accepted by KaTeX Accepted by MathJax Looks like author's LaTeX Looks like normalised LaTeX
mathml latex 20,000 99.7% 100.0% 100.0% 81.3% 68.6%
mathml text 20,000 99.8% - - - -

Measured on 20,000 formulas held out for testing from the mathconv corpus at revision f84cf205ba12. Fully converted: nothing was left unconverted. Accepted: the renderer displays the LaTeX without error. Looks like: where the source also gives LaTeX, both look the same in MathJax.

Documentation

The other documents are in docs.

Contributing

If a formula converts wrongly, open an issue with the wrong-conversion form, giving the MathML and the output you got.

Licence

mathconv is released under the MIT licence. NOTICE covers the W3C data its symbol tables are generated from.

Metadata

Release files for mathconv 0.1.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mathconv 0.1.0a2
File Size Uploaded Provenance Actions
mathconv-0.1.0a2.tar.gz 243.2 kB With provenance Details for mathconv-0.1.0a2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mathconv 0.1.0a2
File Actions
mathconv-0.1.0a2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for mathconv-0.1.0a2-cp310-abi3-win_amd64.whl
mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_x86_64.whl
mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_aarch64.whl
mathconv-0.1.0a2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mathconv-0.1.0a2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
mathconv-0.1.0a2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mathconv-0.1.0a2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
mathconv-0.1.0a2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for mathconv-0.1.0a2-cp310-abi3-macosx_11_0_arm64.whl
mathconv-0.1.0a2-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for mathconv-0.1.0a2-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 4.7 MB

Release files / mathconv-0.1.0a2.tar.gz

Download URL mathconv-0.1.0a2.tar.gz
Size 243.2 kB
Tags Source
SHA-256 checksum
How to use checksums
46b4b5d71929f3ab03d622ca677a5a8efe7ae510c0b09575fba1ee47388aa960
BLAKE2b-256 checksum
How to use checksums
a364fdad114034b8f742c6c5a22a8cc2a6f6368fe66d70ec0df9ca66beffc9f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-win_amd64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-win_amd64.whl
Size 446.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5198f8b2471cbcb6dfa5aff6685292e47ee7c8e0fc59b0bee80dc0fa6282e63c
BLAKE2b-256 checksum
How to use checksums
7b270f1e3ac991371033aa7b3700ecc189eed71a8241102011c66279edc47533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_x86_64.whl
Size 840.8 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
bdab07773b4abaf515af7fb79067ccb29ff16ef26bcb079cb8cd6d5f9338ff9d
BLAKE2b-256 checksum
How to use checksums
eed3bddc6c4161b854a9030c09e5d08627d070333963718b96f6dce6ee935a38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-musllinux_1_2_aarch64.whl
Size 814.5 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
18977ff958e34bc680a54225e427996fb72e6c1170be91a52ff82c239966c16a
BLAKE2b-256 checksum
How to use checksums
c5f95efcb5f7226a9ea1f824f88c88e318f7d2080ba251894ed705e92a521052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 604.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7042b917c1238f272291e8e8a6d64537dcbbc719e8ed2fe189f37ad617980d86
BLAKE2b-256 checksum
How to use checksums
a06e58fc79463e2338f34bb94f6bd37f0b3aa729513d0fe62e45ce8ca94a4bad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 636.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a05f3bc419710edfac5fb2a55185627b5358c8a9e278b80a1989b3999c8e9aa4
BLAKE2b-256 checksum
How to use checksums
25be1d73716bf833d51dce223bd0ccaf030e4ca7993f6b7fe85721bacea4aa99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-macosx_11_0_arm64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-macosx_11_0_arm64.whl
Size 539.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bc89e38d1146bf0edf881db6c260b464bec3e1740fe9a1a9b93b644b3490c785
BLAKE2b-256 checksum
How to use checksums
628dc2b4ec040cfde3f56bd3d3c479dcb7fe8581f72535f2834d778c4fb32b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / mathconv-0.1.0a2-cp310-abi3-macosx_10_12_x86_64.whl

Download URL mathconv-0.1.0a2-cp310-abi3-macosx_10_12_x86_64.whl
Size 546.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
691ef763fffc086e8dc63ef76ac65c15755d350ab26888dfcf971e937e9e4bef
BLAKE2b-256 checksum
How to use checksums
b04c5e33fc0111564960f195d948aadee85582950bd29fb70521805ff69ee83c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for mathconv 0.1.0a2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for mathconv-0.1.0a2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page