Query. Filter.
Transform
Markdown.
What is mq?
mq is a command-line tool that processes Markdown using a syntax similar to jq. It's written in Rust, allowing you to easily slice, filter, map, and transform structured data — no regular expressions or custom scripts required.
Structural, not textual
Queries walk the Markdown AST — matching headings, lists, tables, and code blocks, not raw text.
Built in Rust
A single native binary with no runtime dependencies — built for speed on files large and small.
Familiar jq-like syntax
If you already know jq, you already know how to pipe, filter, and transform with mq — the core ideas carry straight over.
Why mq?
mq makes working with Markdown files as easy as jq makes working with JSON. It's especially useful for:
LLM Workflows
Efficiently manipulate and process Markdown used in LLM prompts and outputs.
Documentation Management
Extract, transform, and organize content across multiple documentation files.
Batch Processing
Apply consistent transformations across multiple Markdown files with sub-millisecond execution.
LLM Input Generation
Generate structured Markdown content optimized for LLM consumption, since Markdown serves as the primary input format for most language models.
Content Analysis
Quickly extract specific sections or patterns from Markdown documents with precise node selection.
Since LLM inputs are primarily in Markdown format, mq provides efficient tools for generating and processing the structured Markdown content that LLMs require.
Features
A comprehensive set of primitives designed for deep structural manipulation of the web's most popular document format.
Slice and Filter
Extract specific parts of your Markdown documents with ease.
Map and Transform
Apply transformations to your Markdown content.
Command-line Interface
Simple and intuitive CLI for quick operations.
Extensibility
Easily extendable with custom functions.
Built-in Support
Filter and transform content with many built-in functions and selectors.
REPL Support
Interactive command-line REPL for testing and experimenting.
IDE Support
VSCode Extension and Language Server Protocol (LSP) support for custom function development.
Debugger
Experimental debugger (mq-dbg)
for inspecting and stepping through mq queries interactively.
External Subcommands
Extend mq with custom subcommands by placing executables
starting with mq- in
~/.local/bin/.
Subcommands
mq can be extended with a variety of specialized subcommands to handle different workflows and data formats.
mq-conv
A powerful tool for converting various file formats (PDF, DOCX, XLSX, etc.) into clean, structured Markdown.
mq-crawler
A web crawler that extracts structured content from websites and outputs it directly in Markdown format.
mq-tui
A terminal-based Markdown viewer that renders content with syntax highlighting and proper formatting.
mq-lsp
Language Server Protocol (LSP) implementation providing IDE features like completion and hover for mq queries.
Custom Subcommands
You can easily extend mq by creating your own subcommands. Any
executable named
mq-<name> in your
~/.local/bin/ or
PATH becomes accessible as
mq <name>.
Try mq right now
Run a query against sample Markdown directly in your browser. For the full editor experience with syntax highlighting, open the full Playground.