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.
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
I'm Sébastien Dubois, and I'm on a mission to help knowledge workers escape information overload. After 20+ years in IT and seeing too many brilliant minds drowning in digital chaos, I've decided to help people build systems that actually work. Through the Knowii Community, my courses, products & services and my Website/Newsletter, I share practical and battle-tested systems.
I write about Knowledge Work, Personal Knowledge Management, Note-taking, Lifelong Learning, Personal Organization, Productivity, and more. I also craft lovely digital products and tools.
If you want to follow my work, then become a member and join our community.
Ready to get to the next level?
If you're tired of information overwhelm and ready to build a reliable knowledge system:
- 📚 KM for Beginners — 10+ hours of structured video lessons
- 🚀 Obsidian Starter Kit — Ready-made vault with 40+ templates
- 💼 Knowledge Worker Kit — Complete guides + lifetime community
- 🦉 1-on-1 Coaching — Personalized guidance
- 🎯 Join Knowii — Community + ALL courses & tools
Found this valuable? Share it with someone who needs it.