A beautiful, interactive terminal database client for PostgreSQL, MySQL, and many compatible databases. Navigate your databases with a tree browser, run SQL in a full-screen REPL — all from your terminal.
╔══════════════════════════════════════╗
║ 🌳 sqltree v1.4 ║
║ PostgreSQL · MySQL · CLI Client ║
╚══════════════════════════════════════╝
PostgreSQL-compatible: PostgreSQL, CockroachDB, Redshift, YugabyteDB, TimescaleDB, Supabase, Neon, AlloyDB, Aurora PostgreSQL
MySQL-compatible: MySQL, MariaDB, TiDB, SingleStore, PlanetScale, Vitess, Aurora MySQL, Percona
- Two-column TUI — tree browser on the left, detail panel on the right
- Interactive tree navigation — browse databases, schemas, tables, and roles with arrow keys
- Full-screen SQL REPL — press
Taborsto enter SQL mode with auto-completion - 20+ databases, one tool — PostgreSQL, MySQL, and many compatible databases with a unified interface
- Database switching — select a different database in the tree to reconnect automatically
- Paginated browsing — press
Enteron a table to browse data page by page - Export — save query results to CSV or JSON
- Saved connections — store and reuse connection profiles
- Tab completion — SQL keywords and table names in REPL mode
- ASCII mode — works in terminals without Unicode/emoji support
- Extensible adapters — register custom database adapters via
registerAdapter()
The easiest way to use sqltree is with npx — no install needed:
# Interactive mode — guided connection setup
npx sqltree
# Connect via URI
npx sqltree --uri postgresql://user:pass@localhost:5432/mydb
npx sqltree --uri mysql://root:secret@127.0.0.1:3306/app
# Connect with individual params
npx sqltree -t postgres -H localhost -p 5432 -U postgres -d mydb
npx sqltree -t mysql -H 127.0.0.1 -U root -d test# Use DATABASE_URL environment variable
DATABASE_URL=postgresql://user:pass@localhost/mydb npx sqltree| Flag | Description |
|---|---|
--uri <url> | Connection URI |
-t, --type <type> | Database type (postgres, mysql, cockroachdb, etc.) |
-H, --host <host> | Database host |
-p, --port <port> | Database port |
-U, --user <user> | Database user |
-P, --password <pass> | Database password |
-d, --database <name> | Database name |
--page-size <n> | Rows per page when browsing tables (default: 50) |
--timeout <ms> | Connection timeout in milliseconds (default: 10000) |
--ssl | Enable SSL for the connection |
--ssl-reject-unauthorized <bool> | Verify SSL certificates (default: true) |
--ascii | Use ASCII characters instead of emoji |
--saved | Use a previously saved connection |
--help | Show help |
--version | Show version |
| Variable | Description |
|---|---|
DATABASE_URL | Fallback connection URI when no arguments are provided |
npm install -g sqltree
sqltree| Key | Action |
|---|---|
↑ / k | Move up |
↓ / j | Move down |
Enter / → / l | Expand node / browse table |
← / h | Collapse node / go to parent |
Tab / s | Enter SQL REPL mode |
d | Describe table structure |
e | Export last result to CSV |
r | Refresh tree |
q | Quit |
| Key | Action |
|---|---|
↓ | Next page |
↑ | Previous page |
← | Exit browse |
w | Scroll up |
s | Scroll down |
| Command | Action |
|---|---|
SQL ending with ; | Execute query |
\back | Return to tree browser |
\export <csv|json> | Export last result |
\save <name> | Save current connection profile |
Ctrl+C | Cancel / return to tree |
Connection profiles are stored in ~/.sqltree/connections.json with file permissions restricted to your user (mode 0600).
⚠️ Warning: Profiles contain passwords in plain text — treat this file as sensitive. Avoid committing it to version control.
- Node.js 20+
- Network access to your database server
New to sqltree? Check out the Getting Started Tutorial — a step-by-step guide covering installation, connecting, tree navigation, the SQL REPL, exporting, config, and more.
See CONTRIBUTING.md for guidelines.