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
|
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
# Install from crates.io
# Install from Github
# Latest Development Version
# Install the debugger
# Install using binstall
Binaries
You can download pre-built binaries from the GitHub releases page:
# macOS (Apple Silicon)
&&
# Linux x86_64
&&
# Linux arm64
&&
# Windows (PowerShell)
Homebrew
# Using Homebrew (macOS and Linux)
Docker
mq-lsp (Language Server)
The mq Language Server provides IDE features like completion, hover, and diagnostics for mq query files.
Quick Install
|
Cargo
# Install from crates.io
# Install from Github
# Latest Development Version
# Install using binstall
Binaries
You can download pre-built binaries from the GitHub releases page:
# macOS (Apple Silicon)
&&
# Linux x86_64
&&
# Linux arm64
&&
# Windows (PowerShell)
Visual Studio Code Extension
You can install the VSCode extension from the Visual Studio Marketplace.
Neovim
You can install the Neovim plugin by following the instructions in the mq.nvim README.
Zed
You can install the Zed extension by following the instructions in the zed-mq README.
GitHub Actions
You can use mq in your GitHub Actions workflows with the Setup mq action:
steps:
- uses: actions/checkout@v6
- uses: harehare/setup-mq@v1
- run: mq '.code' README.md
Web
Playground
The Playground lets you run mq queries in the browser with no install.
Web API
You can try mq without installing anything via the hosted REST API at [https://api.mqlang.org](https://api.mqlang.org).
The interactive API documentation is available at Swagger UI.
mq-web (npm)
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 for details.
Usage
For more detailed usage and examples, refer to the documentation.
For a comprehensive collection of practical examples, see the Example Guide.
Basic usage
)
Here's a basic example of how to use mq:
# Extract all headings from a document
# Extract code blocks containing "name"
# Extract code values from code blocks
# Extract language names from code blocks
# Extract URLs from all links
# Filter table cells containing "name"
# Select lists or headers containing "name"
# Exclude JavaScript code blocks
# Convert CSV to markdown table
# Extract a section by title
# Filter sections by heading level (scalar or range)
Composing Workflows with Subcommands
mq subcommands are designed to work together via Unix pipes.
# Convert Excel report to Markdown, then extract all headings
|
# Convert a Word document and extract a specific section
|
# Convert and view Markdown directly in the terminal
|
Run mq --list to see all available subcommands (built-in and external).
External Subcommands
You can extend mq with custom subcommands by placing executable files starting with mq- in ~/.local/bin/ or anywhere in your PATH.
This makes it easy to add your own tools and workflows to mq without modifying the core binary.
See the External Subcommands documentation for the full list and details.
Support
- 🐛 Report bugs
- 💡 Request features
- ⭐ Star the project if you find it useful!
License
This project is licensed under the MIT License. See the LICENSE file for details.