Visit the site 🌐
—
Read the book 📖
—
Playground 🎮
mq
**Query. Filter. Transform Markdown.**
[](https://github.com/harehare/mq/actions/workflows/ci.yml)
[](https://github.com/harehare/mq/actions/workflows/audit.yml)
[](https://crates.io/crates/mq-markdown)
[](https://codecov.io/gh/harehare/mq)
[](https://codspeed.io/harehare/mq)
[](LICENSE)
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
```bash
curl -sSL https://mqlang.org/install.sh | bash
```
The installer will:
- Download the latest mq binary for your platform
- Install it to `~/.local/bin/`
- Update your shell profile to add mq to your PATH
### Cargo
```sh
# Install from crates.io
cargo install mq-run
# Install from Github
cargo install --git https://github.com/harehare/mq.git mq-run --tag v0.6.5
# 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.6.5
```
### Binaries
You can download pre-built binaries from the [GitHub releases page](https://github.com/harehare/mq/releases):
```sh
# macOS (Apple Silicon)
curl -L https://github.com/harehare/mq/releases/download/v0.6.5/mq-aarch64-apple-darwin -o /usr/local/bin/mq && chmod +x /usr/local/bin/mq
# Linux x86_64
curl -L https://github.com/harehare/mq/releases/download/v0.6.5/mq-x86_64-unknown-linux-gnu -o /usr/local/bin/mq && chmod +x /usr/local/bin/mq
# Linux arm64
curl -L https://github.com/harehare/mq/releases/download/v0.6.5/mq-aarch64-unknown-linux-gnu -o /usr/local/bin/mq && chmod +x /usr/local/bin/mq
# Windows (PowerShell)
Invoke-WebRequest -Uri https://github.com/harehare/mq/releases/download/v0.6.5/mq-x86_64-pc-windows-msvc.exe -OutFile "$env:USERPROFILE\bin\mq.exe"
```
### Homebrew
```sh
# Using Homebrew (macOS and Linux)
brew install mq
```
### Arch
```sh
# Using yay (ArchLinux)
yay -S mq-bin
```
### Docker
```sh
$ docker run --rm ghcr.io/harehare/mq:0.6.5
```
### Visual Studio Code Extension
[](https://marketplace.visualstudio.com/items?itemName=harehare.vscode-mq)
[](https://open-vsx.org/extension/harehare/vscode-mq)
You can install the VSCode extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=harehare.vscode-mq).
For VS Code compatible editors, it is also available on the [Open VSX Registry](https://open-vsx.org/extension/harehare/vscode-mq).
### Neovim
You can install the Neovim plugin by following the instructions in the [mq.nvim README](https://github.com/harehare/mq/blob/main/editors/neovim/README.md).
### Zed
You can install the Zed extension from the [zed-mq](https://github.com/harehare/mq/blob/main/editors/zed/README.md) repository.
### GitHub Actions
You can use mq in your GitHub Actions workflows with the [Setup mq](https://github.com/marketplace/actions/setup-mq) action:
```yaml
steps:
- uses: actions/checkout@v6
- uses: harehare/setup-mq@v1
- run: mq '.code' README.md
```
## Web
### Playground
The [Playground](https://mqlang.org/playground) lets you run mq queries in the browser with no install.
### mq-web (npm)
[mq-web](https://www.npmjs.com/package/mq-web) is the official WebAssembly build for browser.
## Language Bindings
Language bindings are available for Elixir, Python, Ruby, Java, and Go. See the [Language Bindings documentation](https://mqlang.org/book/start/language_bindings.html) for details.
## Usage
For more detailed usage and examples, refer to the [documentation](https://mqlang.org/book/).
For a comprehensive collection of practical examples, see the [Example Guide](https://mqlang.org/book/start/example/).
### Basic usage