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 and an npm 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 810,000 typical formulas a second through convert_batch, 850,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).

For JavaScript and TypeScript, in Node.js, Deno, bundlers and browsers, mathconv is on npm as a WebAssembly build with the same output (JavaScript API):

npm install @mathconv/mathconv

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 documentation covers:

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.0a4

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.0a4
File Size Uploaded Provenance Actions
mathconv-0.1.0a4.tar.gz 254.8 kB With provenance Details for mathconv-0.1.0a4.tar.gz

Built distributions (wheels)

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

Total release size: 4.8 MB

Release files / mathconv-0.1.0a4.tar.gz

Download URL mathconv-0.1.0a4.tar.gz
Size 254.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0b832896cc689e68b1a118a3f018f17bd62c83d14906590970c55b9bba1d4e9e
BLAKE2b-256 checksum
How to use checksums
45b704aca1bd5e96e142091fc1fbfbb91d99c8d7280af81b1069280f0d8e737c
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-win_amd64.whl
Size 454.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
40025ea2a205e7c25db97848aabc9c13402633ea545e28e06c92cd883b40d0ce
BLAKE2b-256 checksum
How to use checksums
bb0f8033898020e541fa6a04a9a072c13cd5b5b42781e5322b22192a8230a527
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-musllinux_1_2_x86_64.whl
Size 851.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
ee5dd2217030796b8c6d52f3ec7b57c4181ed05aa20eff3a92d044a15f5ddbf8
BLAKE2b-256 checksum
How to use checksums
064edcd3ef523e626252b748c697dc27df3ec44b029725cdeb61632f3b316720
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-musllinux_1_2_aarch64.whl
Size 827.5 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
fe6806b21a5150bf7a2638ffbca9816fa141a06935f7d8d7a2fbb525094e76a2
BLAKE2b-256 checksum
How to use checksums
1313223b88ec39be223ba4e8b60738b222c273465cd016ccaaf27b705e0fec21
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 616.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
090f4f41221ba46491af6c0adbcc3bc3503b5cbc8e62e9cf8164f419aa09dec6
BLAKE2b-256 checksum
How to use checksums
723780c4ebc9dd390733c16ccf841c569c2bea900a8e2546ecde4cba57cae939
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 648.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
13f5ce9ec8290179bbf4862da2045afa4b5d1224d661ae8543e708a7335527b9
BLAKE2b-256 checksum
How to use checksums
bc4bea6bd3d29299a42052d9c5916d0d5d43330fb1311d9f9f78944a3257aa9f
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-macosx_11_0_arm64.whl
Size 549.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d35ce9f58e009d5cfa08ba621d898f41106174a5fe221b53d53e79d5bf6afb11
BLAKE2b-256 checksum
How to use checksums
2fd96c0f90a87509c34083eeb04dfdebbe1be811d62d822292a167ddad043704
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 log

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

Download URL mathconv-0.1.0a4-cp310-abi3-macosx_10_12_x86_64.whl
Size 558.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7f3984f0a312843d75290a1ab8f8660367d47d1c5bf8552166eafec775d04b5d
BLAKE2b-256 checksum
How to use checksums
bb18429105e02eb95794162744f38e47c5bfdccb42b281651ea25f90a5387b83
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 log

Security for mathconv 0.1.0a4

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.0a4.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 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