mq: jq for Markdown
Canonical version: mq: jq for Markdown.
If you've ever loved jq for slicing JSON and wished you had the same thing for Markdown, mq is exactly that.
mq is a command-line tool that queries, filters, and transforms Markdown using a jq-inspired syntax. Instead of grepping and sed-ing raw text, you address a document by its actual structure ; headings, code blocks, links, lists, tables ; and map or filter over those elements.
Why this matters now
Large Language Models (LLMs) both consume and emit Markdown constantly. It has quietly become the lingua franca of AI workflows. That makes a structure-aware Markdown processor genuinely useful: cleaning model output, extracting just the code blocks, pulling every heading into an outline, stripping a doc down to the sections you care about before feeding it back to a model.
mq is built for exactly this. A few examples of the mental model:
.h; grab every heading.code("rust"); filter to Rust code blocks only- convert a CSV into a Markdown table, and back
Why I like it
- It's jq for a format that actually dominates my day. The query mindset transfers directly. If you think in jq, you're productive in minutes.
- It's fast. Written in Rust, with great performance, so batch-processing thousands of files is a "non-event".
- The tooling is serious. A REPL, a VSCode extension, Neovim and Zed support, LSP, an experimental debugger, and GitHub Actions integration. It extends git-style by dropping
mq-*executables on yourPATH. - Easy to install. Curl script, Cargo, Homebrew, Docker, or pre-built binaries for macOS, Linux, and Windows. MIT-licensed.
Where grep, sed, and awk are blind to Markdown structure, and Pandoc converts whole documents between formats, mq sits in the gap: surgical queries and transforms within Markdown. For anyone wrangling docs or building LLM pipelines, that's a sharp little tool worth keeping around.
References
- Official website: https://mqlang.org/
- Documentation: https://mqlang.org/book/
- Source code: https://github.com/harehare/mq
Related
About Sébastien
Ready to get to the next level?
Found this valuable? Share it with someone who needs it.