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: the Rust core converts about 240,000 formulas a second on one Apple M3 core, and over a million a second of short formulas (benchmark).
  • 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.5% 100.0% 100.0% 80.5% 68.7%
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.0a1

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

Built distributions (wheels)

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

Total release size: 4.6 MB

Release files / mathconv-0.1.0a1.tar.gz

Download URL mathconv-0.1.0a1.tar.gz
Size 232.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fc5a88bbb055e41d084930cafb3d8ed608d3d6a85f746f1f26959d7b93af542a
BLAKE2b-256 checksum
How to use checksums
52845120dac340cf34f607aaedf1c6951632a5f98bc65b36e714fbd0e9dca3e7
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.0a1-cp310-abi3-win_amd64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-win_amd64.whl
Size 431.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2c24176040f2f3c69c60a2056afa6b35574642c7f9c9b5e726f46505ef9244c5
BLAKE2b-256 checksum
How to use checksums
90f067a439d3a9baa44212b66555b3dbb648f479f28bf74e5b2b1625b0839db4
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.0a1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 826.2 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7ad5ccc6eb5b3f8484b007516c8e584951ccd6f83ccaba45fb3a6621c11a5927
BLAKE2b-256 checksum
How to use checksums
9c862c5762995e9a788d09f362c241149f11a3d55d9375c2aabbbc1623abfe63
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.0a1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 803.4 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
fd550258e2abf0bdf65bf9dbc71462bb56fd7b69cc988eae84effe1f4d33a67b
BLAKE2b-256 checksum
How to use checksums
c2acc5110e6fe5f1b46d6a553edf8cb58848fcce2942115bae46c4d5ff5e61ac
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.0a1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 591.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8840f90028a1ea839a9da6fb8a293a5d70b76696276fbd55f24927ef9cba580d
BLAKE2b-256 checksum
How to use checksums
ca65321c585b4db4397677ae5385bad4d1dfd995ff42eff81e5dd8f1994af555
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.0a1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 625.1 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b1faabce6f6ce9c95e62e6814b404d3ba291f14e265354aa2768a6b2a1967329
BLAKE2b-256 checksum
How to use checksums
3c490753a23afb3e0219262ce64b4b6810fdb15ab69f391045ac824382b5c38e
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.0a1-cp310-abi3-macosx_11_0_arm64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-macosx_11_0_arm64.whl
Size 526.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1bb2118435e85112ec85858b1e4c5a603c7f279f701d8c43e5f4adc9a81ca8d3
BLAKE2b-256 checksum
How to use checksums
202bc749d98974b7c7c406c68349896ebbf1484b164ba646d53c7d880efbb90a
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.0a1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL mathconv-0.1.0a1-cp310-abi3-macosx_10_12_x86_64.whl
Size 534.4 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a262da03c1b11cd3c3804962c1276db528d954378b8453eafc70dd666e4943f9
BLAKE2b-256 checksum
How to use checksums
fed8cfe4ddbc6c118a02c803277fc180acd037f58c2778007b9892849e95d42a
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.0a1

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