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.