1 unstable release
| 0.1.0 | Apr 11, 2026 |
|---|
#819 in Command-line interface
3.5MB
2.5K
SLoC
xnv
Interactive XML navigator and filter with XPath-like queries — inspired by jnv by ynqa.
Overview
xnv is a terminal-based interactive viewer for XML files. Type XPath-like queries to filter and explore the document tree in real time. Results update as you type. When you find what you need, press Enter twice to exit and print the query and output to stdout.
Installation
Homebrew (macOS / Linux)
brew install jaedmunt/tap/xnv
Cargo
cargo install xnv
Prebuilt binaries
Download from the releases page for:
x86_64-unknown-linux-gnux86_64-unknown-linux-muslaarch64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvcaarch64-pc-windows-msvc
Usage
# From a file
xnv data.xml
# From stdin
cat data.xml | xnv
# Start with a default query
xnv data.xml --default-filter '//item'
# Exit and write result to stdout
xnv data.xml --write-to-stdout
Query syntax
| Query | Result |
|---|---|
| (empty) | Show the full document |
//tagname |
All elements named tagname |
/root/child |
Navigate by absolute path |
@attr |
All elements that have attribute attr |
@attr=value |
Elements where attr equals value |
//tag/text() |
Text values only — no XML tags |
Examples
//item → all <item> elements
/catalog/book → <book> elements at that exact path
@id → all elements with an id attribute
@type=premium → elements where type="premium"
//title/text() → just the text inside <title> tags
Keybindings
Global
| Key | Action |
|---|---|
Ctrl+C |
Quit |
Enter × 2 |
Exit and print query + output |
Shift+↑ / Shift+↓ |
Switch focus: query editor ↔ XML viewer |
Ctrl+H |
Toggle help overlay |
Ctrl+T |
Toggle values-only mode |
Ctrl+Q |
Copy current query to clipboard |
Ctrl+O |
Copy current result to clipboard |
Query editor
| Key | Action |
|---|---|
Tab |
Autocomplete XPath |
Ctrl+A |
Move to start of line |
Ctrl+E |
Move to end of line |
Alt+B / Alt+F |
Move by word |
Ctrl+W |
Delete previous word |
Alt+D |
Delete next word |
Ctrl+U |
Clear input |
XML viewer (after Shift+↓)
| Key | Action |
|---|---|
↑ / ↓ |
Move cursor |
Enter |
Collapse / expand element |
Ctrl+P |
Expand all |
Ctrl+N |
Collapse all |
Ctrl+L |
Jump to top |
Ctrl+G |
Jump to bottom |
| Mouse scroll | Scroll results |
Configuration
xnv loads its configuration from:
- Linux / macOS:
~/.config/xnv/config.toml - Windows:
%APPDATA%\xnv\config.toml
The file is created automatically on first run with defaults. You can override any setting — see default.toml for the full reference.
Example customisation
[xml]
indent = 4
[keybinds]
exit = ["Ctrl+C", "Ctrl+D"]
toggle_values = ["Ctrl+T"]
[keybinds.on_xml_viewer]
up = ["Up", "Ctrl+K"]
down = ["Down", "Ctrl+J"]
Features
- Real-time filtering — results update as you type with configurable debounce
- XPath-like queries —
//tag,/path/to/elem,@attr,@attr=value,/text() - Values-only mode — strip tags, show just text content (
//tag/text()) - Collapse / expand — fold any element subtree in the viewer
- Tab completion — autocomplete paths from the document
- Clipboard support — copy queries or results with a single keybind
- Animated prefix — reactive snake animation on the query prompt
- Double-Enter exit — print query + output without leaving the TUI manually
- Cross-platform — Linux, macOS, Windows
Building from source
Requires Rust 1.85+.
git clone https://github.com/jaedmunt/xnv
cd xnv
cargo build --release
./target/release/xnv --help
Acknowledgements
Inspired by jnv by ynqa — the JSON navigator this tool is modelled after.
Built with:
- roxmltree — XML parsing
- promkit — TUI widget framework
- tokio — async runtime
- cargo-dist — release infrastructure
License
MIT
Dependencies
~9–28MB
~383K SLoC