Convert files from your command line
Use our command line tool to convert between different filetypes including PDF using OCR technology. It’s a convenient option when working with documents or images on your local file system.
How to use Mathpix CLI
The first thing you need is to connect your Mathpix account with CLI interface.
Use MPX CLI with your Mathpix account
Just login with your Mathpix account credentials when installing MPX CLI from the command line.
npm install -g @mathpix/mpx-cli
mpx login
More details could be found here: https://github.com/Mathpix/mpx-cli/blob/master/README.md
Use MPX CLI with your API key
Just set your API key as your environment variable when installing MPX CLI from the command line.
npm install -g @mathpix/mpx-cli
export MATHPIX_OCR_API_KEY=...
mpx set-api-key ...
# This will save the key in a file at
# ~/.mpx/config on Linux, macOS, or Unix
# C:\Users\USERNAME\.mpx\config on Windows
Features
Everything you can do from the command line with MPX CLI:
1. Digitize PDFs using OCR
Convert PDFs from your local filesystem to formats like LaTeX, DOCX, HTML, and Markdown using OCR.
mpx convert input-file.pdf output-file.mmd
mpx convert input-file.pdf output-file.docx
mpx convert input-file.pdf output-file.tex
mpx convert input-file.pdf output-file.html
2. Convert document filetypes using MMD
Convert between document formats like LaTeX, DOCX, and HTML using.
mpx convert input-file.mmd output-file.docx
mpx convert input-file.mmd output-file.tex
mpx convert input-file.mmd output-file.html
mpx convert input-file.mmd output-file.pdf
mpx convert input-file.mmd output-file.pdf --pdf-method html
3. Convert images to LaTeX and more
Use the command line to convert images to LaTeX, DOCX, MMD, and HTML like you would with Snip.
mpx convert input-file.png output-file.docx
mpx convert input-file.jpeg output-file.tex
4. Serve local MMD files and directories
Serve local MMD files and directories as a static HTML site.
mpx serve ./input-dir
mpx serve ./input-dir/example.mmd
mpx build ./input-dir ./output-dir