If your Command Prompt window is cluttered with old commands and results, you can clear the visible screen in seconds. In Windows CMD, the built-in cls command removes the text currently displayed in the console and gives you a clean prompt to continue working. It is quick, easy to remember, and does not require installing software or changing system settings.
This guide explains how to clear the screen in CMD, where to type the command, and how to use it in batch files. It also covers what cls does—and does not—clear, how it differs from clearing terminal scrollback, and what to try if the command does not work as expected.
How to Clear the Screen in CMD
To clear the Command Prompt screen, type cls and press Enter. The command clears the visible text in the current CMD window, then displays a fresh command prompt.
Follow these steps:
- Open Command Prompt. You can search for
Command Promptorcmdfrom the Windows Start menu. - Click inside the Command Prompt window so it is active.
- Type
clsat the prompt. - Press
Enter.
For example, if your prompt looks like this:
C:\Users\Alex>
Enter:
cls
After you press Enter, the previous text disappears from the visible screen, and CMD shows the prompt again. You can then enter another command, such as dir, ipconfig, or cd.
What Does the CLS Command Do?
cls is short for “clear screen.” It is a built-in command in Windows Command Prompt, so you do not need to download a utility or enable a special setting. It works in a standard CMD window and can also be used in a Command Prompt session opened from Windows Terminal.
The command clears the text currently visible in the console area. It does not close Command Prompt, restart your computer, or change the folder you are working in. It simply gives you a cleaner view of the active session.
CMD commands are generally not case-sensitive, so cls, CLS, and Cls work the same way. The usual form is lowercase because it is quick to type and easy to recognize.
Does CLS Delete Command History?
No. Clearing the screen is not the same as deleting your command history. The cls command removes previous text from the visible console, but it does not erase the commands you have entered during the current Command Prompt session.
You may still be able to review recent commands by pressing the up-arrow key to cycle through command history. Pressing the down-arrow key moves forward through the commands you have already entered. This history is separate from the text shown on the screen.
Likewise, cls does not delete files, remove command output saved to a file, or undo an operation. If you ran a command that changed a setting or created a file, clearing the screen does not reverse that action. It only clears the console display.
Does CLS Clear the Scrollback Buffer?
Not always. The result depends on the console or terminal application you are using. In a traditional Command Prompt window, cls clears the displayed console area. In Windows Terminal or another terminal app, earlier output may remain accessible by scrolling upward, depending on the app’s settings and how it handles the console.
This distinction matters because the visible screen and the scrollback buffer are not necessarily the same thing. The visible screen is the area you see at the current position. The scrollback buffer stores earlier lines so you can review previous output by scrolling.
If you need to remove old output from view, cls is usually sufficient. If you need to clear the terminal’s scrollback history as well, check the settings or menu for the terminal app you are using. The exact option and keyboard shortcut can vary by application and version.
How to Clear CMD Using a Keyboard Shortcut
In Command Prompt, typing cls is the reliable built-in method. Some terminal applications support keyboard shortcuts such as Ctrl+L to clear or refresh the visible terminal area, but shortcut behavior is not identical across every Windows console, terminal app, or configuration.
If Ctrl+L does not clear your CMD window, use cls instead. It is the standard Command Prompt command and works regardless of whether a particular shortcut is supported.
How to Use CLS in a Batch File
You can use cls in a Windows batch file to clear the screen while a script runs. A batch file is a text file containing commands that CMD executes in sequence. The cls command can be placed wherever you want the current display cleared.
For example, a simple batch file could contain:
@echo off
cls
echo Welcome to the setup menu.
pause
When the script runs, @echo off hides the commands themselves, cls clears the screen, and echo displays a message. The pause command waits for a key press before continuing.
Save the file with a .bat extension, such as menu.bat, and run it from Command Prompt or File Explorer. In a longer script, you can place cls before a menu or status message to keep the display readable. Use it thoughtfully: clearing the screen can also remove helpful output that someone may need to troubleshoot the script.
Can You Clear the Screen in PowerShell?
PowerShell is a different command-line environment from Command Prompt, although both can be opened in Windows Terminal. PowerShell supports the command Clear-Host, which clears the visible console display. In typical PowerShell sessions, cls is also available as an alias for Clear-Host.
That means cls may work in both CMD and PowerShell, but the commands belong to different environments. If you are writing a script intended specifically for PowerShell, Clear-Host makes its purpose clear. If you are writing a batch file for CMD, use cls.
Check which shell you are using before troubleshooting. A CMD prompt often begins with a path such as C:\Users\Alex>, while a PowerShell prompt may look like PS C:\Users\Alex>. Both can display similar commands, but their scripting features and command behavior differ.
Why Is CLS Not Working?
The cls command normally works without extra options. If it does not appear to clear the screen, check the following:
- Confirm you are in a command-line shell. The command is designed for CMD and is also commonly available in PowerShell. It will not work as a command in an ordinary app, website, or text editor.
-
Type the command correctly. Enter
cls, then pressEnter. Do not add punctuation or quotation marks. - Make sure the window is active. Click inside the console before typing. If the cursor is not in the command window, your keystrokes may go somewhere else.
- Check for a custom shell or restricted environment. Some tools that resemble Command Prompt use a different command interpreter and may not support every CMD command.
- Look for scrollback rather than a failed clear. The visible area may be cleared even though older output is still available by scrolling up in your terminal app.
You do not normally need to run Command Prompt as an administrator to use cls. It is a display command, not an operation that requires elevated permissions.
Common CLS Mistakes to Avoid
One common mistake is expecting cls to erase more than it does. It clears the console display, but it does not clear command history, delete logs, or remove output that has already been copied elsewhere. If you need to preserve information, copy it before clearing the window.
Another mistake is typing cls into the Run dialog or a search box and expecting the current CMD window to clear. The command must be entered into an active Command Prompt or compatible shell session. If you start a new CMD window to run it, that new window will be clean, but the original window will remain unchanged.
Finally, remember that clearing the screen does not stop a running command. If a program is still producing output or appears unresponsive, cls may not be the right solution. Wait for the command to finish or use the appropriate interruption method for the task before clearing the display.
Frequently Asked Questions About Clearing CMD
What is the command to clear the screen in CMD? Type cls and press Enter. It is the built-in Command Prompt command for clearing the visible screen.
Is CLS safe to use? Yes. The command clears the console display. It does not delete files or modify Windows settings.
Can I clear CMD without closing the window? Yes. Use cls in the existing Command Prompt session. The window stays open, and you can continue entering commands.
Does CLS work on every version of Windows? cls is a standard command in Windows Command Prompt and is available across commonly used Windows versions. The way scrollback behaves may depend on the console or terminal application.
Conclusion
To clear the screen in CMD, type cls and press Enter. This built-in Windows command quickly removes the text shown in the Command Prompt window without closing your session or changing your current folder. Keep in mind that it clears the visible display—not command history, saved output, or necessarily the terminal’s entire scrollback buffer. For everyday Command Prompt use, however, cls is the simple, reliable way to start with a clean screen.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.