A fast, keyboard-driven terminal UI for MongoDB — inspired by lazygit and lazydocker.

lazymongo demo


Features

  • Sidebar treedatabases expand to show collections; j/k to move, Enter to select, / to search/filter the list
  • Document table — paginated table view with column headers auto-built from the first page of results
  • Detail panel — syntax-highlighted JSON viewer for the selected document with scroll support
  • Responsive layout — adapts from 80 columns upward; full mouse support

Documents

  • Insert a new document in your $EDITOR (n)
  • Edit the selected document in your $EDITOR (e)
  • Clone a document (strips _id, opens editor) (c)
  • Delete a single document with confirmation (dy)
  • Multi-select rows with space, bulk-delete with Dy

Querying

  • Filter with any MongoDB query expression — {"status":"active","age":{"$gt":18}} (/)
  • Filter autocompleteTab completes field names and $ query operators ($gt, $in, $regex, …)
  • Filter history/ in the filter bar to recall previous filters
  • Sort by field name, -field for descending, or a full sort doc — {"field":-1} (s)
  • Reset filter + sort in one keystroke (r)
  • Aggregate — open a pipeline editor, run it, see results tagged [AGG]; recent pipelines offered in a picker (a)
  • Explain plan — see COLLSCAN/IXSCAN, index used, docs/keys examined, execution time; press n on a COLLSCAN to create the missing index pre-filled from your filter (E)

Schema & data tools

  • Schema inference — samples up to 100 docs and shows per-field type breakdown with presence % (S)
  • Import — bulk-insert from .json (array), .jsonl, .ndjson, or .csv with tab-completion for file paths (i)
  • Export — export query results to JSON/CSV (x)
  • Copy _id or full document JSON to clipboard (y / Y)

Indexes

  • List all indexes with keys, flags and stats (I)
  • Create an index from a JSON template in $EDITOR (n inside index panel)
  • Drop a selected index with confirmation (d inside index panel)

Collections & databases

  • Create collection directly from the sidebar (c)
  • Drop collection with two-step confirmation (D on a collection in sidebar)
  • Drop database with two-step confirmation (D on a database in sidebar)

Live & connection features

  • Watch mode — press W on a loaded collection to open a live change-stream overlay; INSERT/UPDATE/REPLACE/DELETE events appear in real time (requires a replica set)
  • Connection health — periodic ping every 15 s; status bar shows latency (◆ 2ms) or offline indicator ()
  • Connection switch — press P to pick any saved profile without restarting (P)

UI & themes

  • 6 built-in themescatppuccin, catppuccin-latte (light), high-contrast, tokyo-night, nord, dracula; cycle with T
  • Nerd Font icons — database/collection/document glyphs in panel titles and the sidebar (disable with ui.nerdFonts: false for unpatched fonts)
  • Toast notifications — copy/export/save confirmations pop up in the top-right corner
  • Typed table cells — numbers, booleans, ObjectIds, dates, and null are colour-coded in the document table
  • Help overlay? shows a full keybinding reference at any time

Install

macOS

curl https://raw.githubusercontent.com/saheersk/lazymongo/main/scripts/install_update_darwin.sh | bash

Or manually:

# Apple Silicon (M1 / M2 / M3)
curl -fsSL https://github.com/saheersk/lazymongo/releases/latest/download/lazymongo_darwin_arm64.tar.gz | tar xz && sudo mv lazymongo /usr/local/bin/

# Intel
curl -fsSL https://github.com/saheersk/lazymongo/releases/latest/download/lazymongo_darwin_amd64.tar.gz | tar xz && sudo mv lazymongo /usr/local/bin/

Or with Homebrew:

brew tap saheersk/tap
brew install lazymongo

Linux

curl https://raw.githubusercontent.com/saheersk/lazymongo/main/scripts/install_update_linux.sh | bash

Or manually:

# amd64
curl -fsSL https://github.com/saheersk/lazymongo/releases/latest/download/lazymongo_linux_amd64.tar.gz | tar xz && sudo mv lazymongo /usr/local/bin/

# arm64 (Raspberry Pi, AWS Graviton)
curl -fsSL https://github.com/saheersk/lazymongo/releases/latest/download/lazymongo_linux_arm64.tar.gz | tar xz && sudo mv lazymongo /usr/local/bin/

Windows

Invoke-WebRequest https://github.com/saheersk/lazymongo/releases/latest/download/lazymongo_windows_amd64.zip -OutFile lazymongo.zip
Expand-Archive lazymongo.zip -DestinationPath "$HOME\bin"

Add $HOME\bin to your PATH via System Properties → Environment Variables → Path → New.


Go

go install github.com/saheersk/lazymongo@latest

Self-update (any install method)

Once lazymongo is installed, update it in place:

lazymongo --update
# Checking for updates…
# Current: v0.4.1
# Latest:  v0.5.0
# Downloading v0.5.0 (darwin/arm64)…
# ✓  Updated to v0.5.0 — restart lazymongo.

If the binary lives in a system directory you'll need sudo lazymongo --update.

Requires Go 1.21+. Binary lands in $(go env GOPATH)/bin.


Build from source

git clone https://github.com/saheersk/lazymongo
cd lazymongo
go build -o lazymongo .

Quick start

# Local MongoDB (default: mongodb://localhost:27017)
lazymongo

# Explicit URI
lazymongo --uri "mongodb://localhost:27017"

# Atlas / remote cluster
lazymongo --uri "mongodb+srv://user:[email protected]"

# Host and port separately
lazymongo --host 192.168.1.10 --port 27017

# Named profile shorthand
lazymongo local

Configuration

On first run, lazymongo writes ~/.config/lazymongo/config.yaml:

connections:
  - name: local
    uri: mongodb://localhost:27017
    default: true
    theme: catppuccin   # per-profile theme override

ui:
  theme: catppuccin     # catppuccin | catppuccin-latte | high-contrast | tokyo-night | nord | dracula
  mouse: true
  pageSize: 50
  nerdFonts: true       # set false if your terminal font has no Nerd Font glyphs
  editor: ""            # leave empty to use $EDITOR / $VISUAL / vim

Named profiles

Save a connection and give it a name:

# Save profiles
lazymongo --uri mongodb://localhost:27017 --save local
lazymongo --uri "mongodb+srv://user:[email protected]" --save atlas

# Connect by name
lazymongo local
lazymongo --profile atlas

When more than one profile exists and none is specified, a picker appears on launch. Inside the app, press P at any time to switch profiles without restarting.

Themes

Cycle through all themes with T, or set one per profile:

connections:
  - name: production
    uri: mongodb+srv://...
    theme: high-contrast
  - name: local
    uri: mongodb://localhost:27017
    theme: catppuccin

Available themes: catppuccin · catppuccin-latte (light) · high-contrast · tokyo-night · nord · dracula


Keyboard reference

Global

Key Action
h / Focus sidebar
l / Focus documents
? Toggle help overlay
T Cycle theme
P Switch connection profile
esc Close overlay / go back
q / Ctrl+C Quit
Key Action
j / Move down
k / Move up
Enter Expand database / select collection
/ Search / filter sidebar list
c Create collection
D Drop collection or database (2-step confirm)
R Refresh list

Document list

Key Action
j / Next row
k / Previous row
g First row
G Last row
Ctrl+D Next page
Ctrl+U Previous page
Enter Open detail panel
n New document ($EDITOR)
e Edit document ($EDITOR)
c Clone document ($EDITOR, _id stripped)
d Delete document (y to confirm)
space Toggle row selection (multi-select)
D Bulk-delete selected rows (y to confirm)
/ Filter — any MongoDB query JSON
/ (in filter bar) Browse filter history
s Sort — field, -field, or {"field": -1}
r Reset filter and sort
a Aggregate pipeline editor
E Explain plan overlay
S Schema inference overlay
i Import from file (JSON / JSONL / CSV)
x Export results
W Watch collection — live change stream
I Toggle index panel
y Copy _id to clipboard
Y Copy full document JSON to clipboard
R Refresh current page

Filter / sort bar

Key Action
Enter Apply
Esc Cancel (closes the completion dropdown first if open)
Ctrl+U Clear input
Tab Autocomplete field names / $ operators (cycle matches)
/ Browse filter history (or dropdown when open)

Aggregate mode

Press a to open your $EDITOR with a pipeline template. If you've run pipelines before, a picker appears first with your 10 most recent pipelines (/ select, Enter edit, Esc cancel):

[
  { "$match": {} }
]

Save and close to run. Results appear tagged [AGG].

Key Action
a Re-open editor (last pipeline pre-filled)
esc Exit aggregate mode, return to live view

While viewing [AGG] results, filter/sort/edit/export keys show a reminder that they operate on the live collection — exit agg mode first.

Pipelines without $limit, $out, or $merge automatically get {"$limit": 1000} appended.

Index panel (I)

Key Action
j / k Navigate indexes
g / G First / last
n Create index ($EDITOR opens with template)
d Drop selected index (y to confirm)
R Refresh
esc / h Close panel

Index creation template:

{
  "keys": { "fieldName": 1 },
  "unique": false,
  "sparse": false,
  "ttlSeconds": -1
}

Use 1 / -1 for ascending/descending, "text" for full-text indexes. Set ttlSeconds to a value ≥ 0 to create a TTL index (-1 disables it).

Explain plan overlay (E)

Shows the winning plan for the current query:

  • IXSCAN — index name, keys examined, selectivity
  • COLLSCAN — warning for missing index, plus n to open the index editor pre-filled with the fields of your current filter
  • Execution time and docs returned

Press n to create the suggested index, any other key to close.

Schema overlay (S)

Samples up to 100 documents and shows:

  • Every field found, sorted by frequency
  • BSON type breakdown (string, int32, objectId, …)
  • Presence percentage

j / k to scroll, any other key to close.

Import overlay (i)

Key Action
Tab Autocomplete file path (shell-style, ~/ supported)
Enter Run import
Esc Cancel

Supported formats: .json (array) · .jsonl · .ndjson · .csv

Inserts in batches of 500. Duplicate-key errors are skipped and counted; the rest still insert.

Watch overlay (W)

Requires a MongoDB replica set (standalone instances don't support change streams).

Key Action
j / k Scroll event list
W / esc Stop watching and close

Events show operation type (INSERT / UPDATE / REPLACE / DELETE), document ID, a field preview, and a relative timestamp. Newest events appear at the top; up to 100 events are kept in the buffer.

Connection picker (P)

Key Action
j / k Navigate profiles
Enter Connect to selected profile
Esc Cancel

Selecting a profile disconnects the current client and reconnects without restarting the app. The sidebar and document list reset automatically.

Detail panel

Key Action
j / Scroll down
k / Scroll up
esc / h Close

Editor integration

lazymongo opens documents and pipelines in $EDITOR (fallback: $VISUAL, then vim). Multi-word commands work:

ui:
  editor: "code --wait"
  # editor: "nvim"
  # editor: "nano"

Temp files are created as /tmp/lazymongo-*.json in MongoDB Extended JSON format. Save and close to apply; delete all content or quit without saving to cancel.


Connection health

A background ping runs every 15 seconds:

  • ◆ localhost:27017 2ms — connected, latency shown
  • ◇ localhost:27017 — connection lost

On reconnect the indicator returns to automatically.


Watch mode

Watch mode uses MongoDB change streams and requires a replica set (or Atlas). A standalone mongod will show an error immediately.

To start a local single-node replica set for testing:

mongod --replSet rs0 --dbpath /tmp/rs0 --port 27017 --fork --logpath /tmp/rs0.log
mongosh --eval "rs.initiate()"

Then press W on any collection to start watching.


Compatibility

MongoDB Status
4.x Supported
5.x Supported
6.x Supported
7.x Supported
Atlas Supported
Platform Status
macOS Tested
Linux Tested
Windows (WSL) Tested

Requires MongoDB Go driver v2.


Development

# Run all tests
go test ./...

# Integration tests (requires MongoDB on localhost:27017)
go test ./internal/mongo/... -v

# Build
go build -o lazymongo .

Tests use the lazymongo_test database and clean up after themselves.


Project layout

.
├── main.go
├── cmd/
│   ├── root.go          # cobra CLI, flag parsing, config loading
│   └── picker.go        # startup profile picker
├── internal/
│   ├── config/          # viper-backed YAML config, named profiles
│   ├── mongo/           # MongoDB client, CRUD, aggregate, indexes,
│   │                    # explain, schema, import, health, watch
│   ├── util/            # BSON↔JSON, clipboard, syntax highlight, export, import parse
│   └── tui/
│       ├── app.go       # root bubbletea model, message routing, overlays
│       ├── msg/         # shared message types (no import cycles)
│       ├── keymap/      # all key bindings
│       ├── style/       # lipgloss themes (6 built-in)
│       └── panels/
│           ├── sidebar/    # database + collection tree, search, create/drop
│           ├── documents/  # paginated table, filter/sort/agg/multi-select
│           ├── detail/     # single-document JSON viewer
│           ├── indexes/    # index list, create, drop
│           └── statusbar/  # bottom status line, health indicator
└── assets/
    └── screenshot.png