This release is a pre-release and may not be stable for production use.
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. Try it in the browser at mathconv.dev.
- 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 800,000 typical formulas a second through
convert_batch, 840,000 in the Rust core, on one core of a GitHub-hosted runner (measured on 2026-12-04). - 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
- Usage: the API and its options.
- LaTeX output style: what the output looks like and why.
- Testing: how quality is measured.
- Contributing: reporting problems and changing the code.
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. Report security problems privately, as the security policy describes. Other questions can go to hello@mathconv.dev.
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.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mathconv-0.1.0a3.tar.gz | 254.3 kB | With provenance | Details for mathconv-0.1.0a3.tar.gz |
Built distributions (wheels)
Total release size: 4.8 MB
Release files / mathconv-0.1.0a3.tar.gz
| Download URL | mathconv-0.1.0a3.tar.gz |
|---|---|
| Size | 254.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f092409dfeab4ac22b20eee28e407351f344b17e4c4c2e3e2083caa08c4dd07
|
|
BLAKE2b-256 checksum How to use checksums |
d264d7e5901bb8f681f10685ba8e51ec791ebb0908dee4e2ae2b7de645e261b8
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-win_amd64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 453.9 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8c20e8bbd41d5f202e1bdaf61be91805ec9a591c59f396a36085375390421796
|
|
BLAKE2b-256 checksum How to use checksums |
6fa4f144ae791c96442fddc06649c12b24d3c12cad5805cb7a286c79fda08247
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 851.6 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3cdf4e36ccbb9232cb51f95c7f8818ba77d7ded1a680e8b0a1f7e52cfb9878f6
|
|
BLAKE2b-256 checksum How to use checksums |
d043620e88538561ace051ad320a2f2fe99e9985bf04adef1a42f054e6a51994
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 827.4 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
364a74f45d76970000a1561c15745a6221d9894253f5ad114472a7661c8f0372
|
|
BLAKE2b-256 checksum How to use checksums |
9e9654cbcd155b16f6628b3311a7823ac16b817f57b049a8e52c2b112a6d8665
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 616.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
482570bcab56f1378b5cdc85762a13940b01c3b539d821a5547e8c227d275c48
|
|
BLAKE2b-256 checksum How to use checksums |
eb20b60997921491b7f19083d0d30872698941dee009dfc20d2aca77766c61ab
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 648.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
02cf4933ac792a5f6f165be0f684a4b349640c09ef3131581a164e721f46a02a
|
|
BLAKE2b-256 checksum How to use checksums |
e6887842d4adaa074e3b9ab4fe5eccc0528aafda8305a8de1b0d2f2279a5f7a3
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 549.0 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0257365d28344a5ac4df797e16e6036b821bd021bb1af8d1a6c1f54bb776da50
|
|
BLAKE2b-256 checksum How to use checksums |
0e01b51f3a2efd15677315143bd397b36d536dab65dbb84e3b7c88d86d91c453
|
| 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 4, 2026.
Transparency logRelease files / mathconv-0.1.0a3-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | mathconv-0.1.0a3-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 558.3 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c0333cfe0e0ca5616baee1bc856092bfc153a21bd622c231dbb74b7a9c63d978
|
|
BLAKE2b-256 checksum How to use checksums |
655f6503e1e465dcf09380471b7ecefa16a325148514a6c91e4f04b9d5eb32b8
|
| 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 4, 2026.
Transparency logSecurity for mathconv 0.1.0a3
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.
Attestation for mathconv-0.1.0a3.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 4, 2026.
Transparency logA 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.