# mq (CLI) mq is a command-line tool that **queries, filters, and transforms [[Markdown]]** using a syntax inspired by [[jq]]. Built by harehare, it is to Markdown what jq is to JSON: a small, composable language for slicing documents into exactly the parts you want and reshaping them programmatically. > Query. Filter. Transform Markdown. The category is **structured Markdown processing**. Instead of grepping and sed-ing raw text, you address a document by its semantic structure ; headings, code blocks, links, lists, tables ; and map or filter over those elements. ## Why It Exists Markdown is now the lingua franca of [[Large Language Models (LLMs)]] ; models both consume and emit it constantly. mq targets that reality: batch-extracting, cleaning, and reshaping Markdown at scale for LLM pipelines, documentation management, and content analysis. The jq mental model transfers directly, so anyone who already thinks in queries is productive fast. ## Core Operations - **Slice and filter** ; extract specific sections (e.g. `.h` for headings, `.code("rust")` for Rust code blocks) - **Map and transform** ; apply modifications across matched elements - **Built-in functions** ; an extensive library for filtering and transformation - **Format conversion** ; read/write JSON, CSV, YAML, XML, HTML and more (e.g. CSV → Markdown table) ## Tooling & Ecosystem - **REPL** for interactive query development - **Editor integration**: VSCode extension, [[Neovim]], Zed - **Language Server Protocol** support via [[Language Server Protocol (LSP)|LSP]] - **Experimental debugger** (`mq-dbg`) - **Extensibility**: custom subcommands by dropping `mq-*` executables on `PATH` (same pattern as git) - **CI**: [[GitHub Actions]] support ## Technical Profile Written in [[Rust]], which gives it sub-millisecond execution suitable for batch processing thousands of files. Distributed under the [[MIT License]]. ## Installation Multiple channels: - Quick install script (`curl`) - Cargo (`cargo install`) - Pre-built binaries for macOS, Linux, Windows - [[Homebrew]] - [[Docker]] ## Where It Fits - **vs [[jq]]**: same query philosophy, but the domain is Markdown documents rather than JSON ; the right tool when the structure you care about is headings/links/code, not nested objects - **vs `grep` / `sed` / `awk`**: those operate on lines of text and are blind to Markdown structure; mq understands the document model, so "give me every Rust code block under a level-2 heading" is a query, not a regex nightmare - **vs [[Pandoc]]**: Pandoc converts whole documents between formats; mq surgically queries and transforms *within* Markdown ## References - Official website: https://mqlang.org/ - Documentation: https://mqlang.org/book/ - Source code: https://github.com/harehare/mq ## Related - [[jq]] - [[Markdown]] - [[Command Line Interface (CLI)]] - [[Rust]] - [[Large Language Models (LLMs)]] - [[Language Server Protocol (LSP)]] - [[Docker]] - [[Homebrew]] - [[GitHub Actions]]