How to clear console in MongoDB?

To clear the console in MongoDB shell, you can use either a keyboard shortcut or the cls command. Both methods instantly clear the terminal display, giving you a clean workspace.

Syntax

Method 1: Keyboard Shortcut

Ctrl + L

Method 2: Command

cls

Method 1: Using Ctrl + L (Recommended)

The fastest way to clear the MongoDB console is using the keyboard shortcut. Simply press Ctrl + L while in the MongoDB shell ?

> use myDatabase switched to db myDatabase > db.users.find() { "_id" : ObjectId("..."), "name" : "John" } > Press Ctrl + L to clear

This shortcut works on most operating systems and terminals.

Method 2: Using cls Command

Alternatively, type cls and press Enter to clear the console ?

> cls

After pressing Enter, the console screen will be cleared, leaving only a fresh prompt.

Key Points

  • Ctrl + L is the fastest method and works across different platforms.
  • cls command provides the same result but requires typing.
  • Both methods only clear the display ? your command history remains intact.
  • Use history command to view previous commands even after clearing.

Conclusion

Use Ctrl + L for quick console clearing or type cls for the same result. Both methods provide a clean workspace while preserving your MongoDB session and command history.

Updated on: 2026-03-15T00:11:00+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements