DEV Community

Arthur031221
Arthur031221

Posted on

snipmd, an offline Mathpix Snip alternative for macOS

A textbook equation becomes LaTeX

I kept running into the same small task: an equation sits in a PDF or a lecture slide, and I need it as LaTeX to paste into my notes or a paper. Retyping it by hand is slow and easy to get wrong.

Mathpix Snip solves this well. Press a hotkey, drag a box, get LaTeX. The problem is the free plan stops at 10 snips a month, Pro costs 4.99 dollars a month, and every snip goes to their servers. LaTeX-OCR is free and local, but it only reads one equation at a time and has not had a commit since January 2025.

So I built snipmd. Same hotkey and drag interaction, but it runs GLM-OCR, a 0.9B model, on your own machine. On Apple Silicon it runs in process through MLX. On other machines it falls back to Ollama. Four modes: Markdown with inline and block math, a bare LaTeX equation ready to paste into a math field, a table as Markdown or CSV, and plain text through Apple Vision for when you do not need the model at all.

How it works

A global hotkey starts the native macOS crosshair selector. The crop is flattened onto white and padded, because tight crops with glyphs touching the edge read worse. GLM-OCR reads the image, and post-processing strips code fences, normalizes LaTeX delimiters, removes the model's odd token spacing, and converts HTML tables to Markdown or CSV. The result goes to the clipboard, a notification shows it, and it is saved to a local history file.

Does it work

I built a benchmark: 48 equations covering fractions, integrals, matrices, sums, Greek letters, and case statements, rendered with a real TeX engine and rasterized the way a screen actually shows them. snipmd matched all 48 after normalizing for equivalent notation, such as pmatrix versus a raw array. Median latency was 0.5 seconds from mouse release to clipboard, with the model already loaded. The method, the equation set, and the scoring rules are all in the repository's bench/ folder, not just claimed in the README.

What is rough

Handwriting has not been measured, since GLM-OCR is trained mostly on printed documents. A full multi-column page can come back in the wrong reading order, because snipmd sends the crop as one image with no layout analysis. Snip one column at a time for now.

snipmd is free, MIT licensed, and runs entirely on your machine. The code, the benchmark, and a comparison with Mathpix Snip, LaTeX-OCR, and Pix2Text are on GitHub: https://github.com/Arthur031221/snipmd

Top comments (0)