Visit the site 🌐
—
Read the book 📖
—
Playground 🎮
mq
Query. Filter. Transform Markdown.
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.

[!IMPORTANT]
This project is under active development.
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
- LLM Input Generation: Generate structured Markdown content optimized for LLM consumption, since Markdown serves as the primary input format for most language models
- Documentation Management: Extract, transform, and organize content across multiple documentation files
- Content Analysis: Quickly extract specific sections or patterns from Markdown documents
- Batch Processing: Apply consistent transformations across multiple Markdown files
Since LLM inputs are primarily in Markdown format, mq provides efficient tools for generating and processing the structured Markdown content that LLMs require.
Features
- 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: Includes an experimental debugger (
mq-dbg) for inspecting and stepping through mq queries interactively.
- External Subcommands: Extend mq with custom subcommands by placing executable files starting with
mq- in ~/.local/bin/.
Installation
Quick Install
curl -sSL https://mqlang.org/install.sh | bash
Downloads the latest mq binary for your platform, installs it to ~/.local/bin/, and updates your shell profile to add mq to your PATH.
On Windows (PowerShell):
powershell -c "irm https://mqlang.org/install.ps1 | iex"
Package Managers
| Method |
Command |
| Homebrew (macOS/Linux) |
brew install mq |
| MacPorts (macOS) |
sudo port install mq |
| Scoop (Windows) |
scoop bucket add mq https://github.com/harehare/scoop-mq && scoop install mq/mq |
| Arch (yay) |
yay -S mq-bin |
| Cargo (crates.io) |
cargo install mq-run |
| Docker |
docker run --rm ghcr.io/harehare/mq:latest |
More install options: cargo variants, binstall, pre-built binaries
# Install from Github
cargo install --git https://github.com/harehare/mq.git mq-run --tag v0.10.2
# Latest Development Version
cargo install --git https://github.com/harehare/mq.git mq-run --bin mq
# Install the debugger
cargo install --git https://github.com/harehare/mq.git mq-run --bin mq-dbg --features="debugger"
# Install using binstall
cargo binstall mq-run@0.10.2
Pre-built binaries for macOS, Linux, and Windows are also available on the GitHub releases page.
Editor & CI Integrations
| Integration |
Link |
| VS Code |
|
| Chrome |
|
| Neovim |
|
| Zed |
|
| JetBrains IDEs |
|
| Obsidian |
|
| Helix |
|
| GitHub Actions |
|
steps:
- uses: actions/checkout@v7
- uses: harehare/setup-mq@v1
- run: mq '.code' README.md
Packages
mq is a Rust + TypeScript monorepo.
Rust crates and npm packages (click to show)
| Name |
Description |
Version |
mq-run |
Command-line interface for mq |
|
mq-lang |
Core language implementation |
|
mq-syntax |
Lexer, AST parser and CST parser |
|
mq-markdown |
Markdown parsing and manipulation utilities |
|
mq-lsp |
Language Server Protocol implementation |
|
mq-repl |
Interactive REPL |
|
mq-formatter |
Code formatter for the mq query language |
|
mq-lint |
Static analysis linter |
|
mq-check |
Type checker |
|
mq-hir |
High-level Internal Representation (HIR) |
|
mq-dap |
Debug Adapter Protocol implementation |
|
mq-crawler |
Directory crawler for batch Markdown processing |
|
mq-macros |
Procedural macros for builtin function registration |
|
mq-test |
Test runner for mq |
|
mq-ffi |
C API for integrating mq into C applications |
- |
mq-wasm |
WebAssembly bindings |
- |
mq-web |
Official WebAssembly build for the browser |
|
mq-nodejs |
Node.js bindings |
|
mq is also available as a hosted REST API (see mq-web-api). See the REST API docs or try it in the Playground.
curl --data-binary @doc.md https://api.mqlang.org/.h1
Language Bindings
Language bindings are available for Elixir, Python, Ruby, Java, and Go. See the Language Bindings documentation for details.
Usage
For more detailed usage and examples, refer to the documentation.
Looking for a solution to a specific problem? See the Cookbook for task-first recipes, or the Example Guide for a full tour of mq's selectors and built-in functions.
Basic usage
Complete list of options (click to show)