Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

treemd

> 开发工具
Open source

A (TUI/CLI) markdown navigator with tree-based structural navigation.

669 stars0 likes3 views
WebsiteGitHub

About

A (TUI/CLI) markdown navigator with tree-based structural navigation.

treemd

A markdown navigator with tree-based structural navigation. Like the tree command, but interactive—navigate markdown documents using an expandable/collapsible heading tree with a synchronized content view.

Table of Contents

  • Overview
  • Features
    • Interactive TUI
    • CLI Mode
  • Installation
  • Usage
    • TUI Mode
    • CLI Mode
    • Query Language
  • Releases
  • Configuration
    • Basic Settings
    • Custom Keybindings
    • Custom Theme Colors
  • Contributing
  • Roadmap
  • Why treemd?
  • Similar Tools
  • License

Overview

treemd is a modern markdown viewer that combines the structural clarity of the tree command with powerful interactive navigation. Whether you're exploring large documentation files, analyzing markdown structure, or reading comfortably in your terminal, treemd provides both CLI tools for scripting and a beautiful TUI for interactive exploration.

Use it to:

  • Navigate large documents by collapsing/expanding heading sections
  • Search headings or full document content with highlighted matches
  • Edit tables, toggle checkboxes, and follow links—all without leaving the terminal
  • Extract specific sections or query markdown elements with a jq-like syntax
  • Pipe markdown from stdin for shell-scripted workflows

Features

Interactive TUI

Feature Description
Dual-pane interface Navigate the outline while viewing synchronized content
Interactive mode Navigate, edit, and interact with tables, checkboxes, links, and code blocks
Table editing Navigate cells with vim keys (hjkl), edit in-place, copy cells/rows/tables
Checkbox toggling Toggle task list items with instant file updates
Live editing Open files in your editor with auto-reload (respects $VISUAL/$EDITOR)
Link following Follow markdown links via visual popup—supports anchors, files, wikilinks, and URLs
Navigation history Go back/forward between files with full state preservation
Syntax highlighting 50+ languages via syntect
Vim-style navigation j/k, g/G, d/u, p (parent)
Search & filter Filter headings (s) or search content (/) with n/N navigation
Command palette Fuzzy-search every command with :—no need to memorize keys
Collapsible tree Expand/collapse sections with Space/Enter
Bookmarks Mark positions (m) and jump back (')
Callouts GFM alerts and Obsidian callouts (> [!NOTE], > [!WARNING], …) rendered with icons and accent colors
Remote documents Open URLs directly: treemd https://… or treemd github:owner/repo
8 color themes Nord, Dracula, Solarized, Monokai, Gruvbox, Tokyo Night, Catppuccin Mocha, Ocean Dark
Customizable keybindings Remap any key via config file

CLI Mode

Feature Description
Query language jq-like syntax for extracting markdown elements
List headings Quick overview with -l
Tree visualization Hierarchical display with --tree
Section extraction Extract by heading name with -s
Smart filtering Filter by text or level (--filter, -L)
Line ranges Append each heading's [start-end] line range with -n
Multiple formats Plain text or JSON output (-o json)
Statistics Count headings by level (--count)
Stdin support Pipe markdown content (cat doc.md | treemd -q '.h')

Pro tip: Combine --tree with --section for rapid navigation of large files. The query language brings jq-like power to markdown extraction.

Installation

From crates.io

bash
cargo install treemd

From source

bash
git clone https://github.com/epistates/treemd
cd treemd
cargo install --path .

Package managers

Homebrew (macOS/Linux):

bash
brew install treemd

Arch Linux (extra repo):

bash
pacman -S treemd

NetBSD:

bash
pkgin install treemd

Shell completions & man page

bash
treemd --setup-completions   # Interactive tab-completion setup (bash/zsh/fish)
treemd --man-page > treemd.1 # Generate the man page (for packagers)

Completions are context-aware: they only offer .md/.markdown files and directories.

Usage

TUI Mode (Interactive)

bash
treemd README.md                  # Open a file
treemd github:rust-lang/rust      # Read a GitHub repo's README
treemd https://example.com/doc.md # Open any markdown URL

Launch the interactive interface by running treemd with a file:

bash
treemd README.md        # Open specific file
treemd .                # Open file picker in current directory
treemd docs/            # Open file picker in specified directory
treemd *.md             # Open file picker with matched files

Keyboard Shortcuts

Navigation

Key Action
j / k or ↓ / ↑ Move down/up
g / G or Home / End Jump to top/bottom
p Jump to parent heading
d / u or PageDown / PageUp Page down/up
Tab / Shift+Tab Switch focus between outline and content
5j etc. Repeat motion with a vim count prefix (digits 1-9 start a count, shown in the status bar)

Tree Operations

Key Action
Enter / Space Toggle expand/collapse
h / l or ← / → Collapse/expand heading
w Toggle outline visibility
[ / ] Adjust outline width (20%, 30%, 40%)
# Toggle heading level markers in outline
T Filter outline by open todos

Search

Key Action
s Search/filter headings in outline
/ Search document content
Tab (in search) Toggle between outline and content search
n / N Next/previous match
Esc Exit search mode

Link Following

Key Action
f Enter link follow mode
Tab / Shift+Tab Navigate links
1-9 Jump to link by number
Enter Follow selected link
b / Backspace Go back
F (Shift+F) Go forward
Esc Exit link mode

Interactive Mode

Key Action
i Enter interactive mode
j / k Navigate elements
Tab / Shift+Tab Next/previous link within element
Enter Activate element
Space Toggle checkboxes/details
y Copy content
Esc Exit interactive mode

Table Navigation (within interactive mode)

Key Action
h / j / k / l Navigate cells
y Copy cell
Y Copy row
r Copy table as markdown
Enter Edit cell
Esc Exit table mode

Commands & System

Key Action
: Open command palette (fuzzy-search commands)
o / Ctrl+o Open file picker
b / Backspace Go back in file history
F (Shift+F) Go forward in file history
r Toggle raw markdown source
M Toggle mouse capture (turn off to select text)
e Edit file in $VISUAL or $EDITOR
t Open theme picker (live preview)
y Copy current section
Y Copy anchor link
m Set bookmark
' Jump to bookmark
? Toggle help overlay
q Quit (Esc backs out of searches/modes)

Selecting and copying text

treemd captures the mouse for scroll-wheel navigation, which by default suppresses your terminal's native click-drag selection. To grab an arbitrary substring:

  • Hold Shift while dragging — most terminals (iTerm2, kitty, GNOME Terminal, Konsole, Windows Terminal) bypass application mouse capture and select natively.
  • Press M to release mouse capture entirely, then select and copy as usual; press M again to restore scroll-wheel navigation.

For whole sections, y copies the current section straight to the clipboard without leaving treemd.

CLI Mode (Non-Interactive)

List headings

bash
treemd -l README.md

Show heading tree

bash
treemd --tree README.md

Extract a section

bash
treemd -s "Installation" README.md

Filter and level options

bash
treemd -l --filter "usage" README.md    # Filter by text
treemd -l -L 2 README.md                # Only ## headings

Count and JSON output

bash
treemd --count README.md                # Count by level
treemd -l -o json README.md             # JSON output

Line ranges

bash
treemd -l -n README.md                  # Each heading with its [start-end] line range
treemd --tree -n README.md              # Same, in tree form

Useful for LLM-driven workflows: read the heading list first, then fetch only the line range for the section that matters instead of the whole file.

Query Language

treemd includes a powerful jq-like query language for extracting markdown elements. Use -q to execute queries and --query-help for full documentation.

Element Selectors

bash
treemd -q '.h' doc.md         # All headings
treemd -q '.h2' doc.md        # Level 2 headings
treemd -q '.code' doc.md      # Code blocks
treemd -q '.link' doc.md      # Links
treemd -q '.img' doc.md       # Images
treemd -q '.table' doc.md     # Tables

Filters and Indexing

bash
treemd -q '.h2[Features]' doc.md       # Fuzzy match
treemd -q '.h2["Installation"]' doc.md # Exact match
treemd -q '.h2[0]' doc.md              # First h2
treemd -q '.h2[-1]' doc.md             # Last h2
treemd -q '.h2[1:3]' doc.md            # Slice
treemd -q '.code[rust]' doc.md         # By language

Pipes and Functions

bash
treemd -q '.h2 | text' doc.md                    # Get text (strips ##)
treemd -q '[.h2] | count' doc.md                 # Count elements
treemd -q '[.h] | limit(5)' doc.md               # First 5
treemd -q '.h | select(contains("API"))' doc.md  # Filter
treemd -q '.h2 | text | slugify' doc.md          # URL slug
treemd -q '.link | url' doc.md                   # Extract URLs

Hierarchy Operators

bash
treemd -q '.h1 > .h2' doc.md           # Direct children
treemd -q '.h1 >> .code' doc.md        # All descendants
treemd -q '.h1[Features] > .h2' doc.md # Combined

Aggregation

bash
treemd -q '. | stats' doc.md           # Document statistics
treemd -q '. | levels' doc.md          # Heading counts by level
treemd -q '. | langs' doc.md           # Code blocks by language

Output Formats

bash
treemd -q '.h2' --query-output json doc.md        # JSON
treemd -q '.h2' --query-output json-pretty doc.md # Pretty JSON
treemd -q '.h2' --query-output jsonl doc.md       # JSON Lines

Stdin Support

bash
cat doc.md | treemd -q '.h2'
curl -s https://raw.githubusercontent.com/.../README.md | treemd -q '.h'
tree | treemd                          # Pipe tree output to TUI

Run treemd --query-help for complete documentation.

Releases

Pre-built Binaries

Download from the releases page:

Platform Binary
Linux x86_64 treemd-x86_64-unknown-linux-gnu
Linux ARM64 treemd-aarch64-unknown-linux-gnu
macOS x86_64 treemd-x86_64-apple-darwin
macOS ARM64 (Apple Silicon) treemd-aarch64-apple-darwin
Windows x86_64 `treemd-x86_64-pc-windows-msvc.e

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustclimarkdownmdterminal

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具