If your Command Prompt window is crowded with old commands and output, clearing the screen is quick. In Windows Command Prompt, type cls and press Enter. The visible text disappears, leaving a clean screen for your next command. The command works in Windows 10 and Windows 11 and does not require administrator access. Below, you’ll learn how to clear CMD, what the command does and doesn’t remove, and how the process differs in PowerShell and Windows Terminal.
How to Clear the Command Prompt Screen
To clear the screen in CMD, use the built-in cls command:
- Open Command Prompt.
- At the prompt, type
cls. - Press Enter.
CMD clears the visible text in the current window and displays a fresh prompt. You can then continue working without closing Command Prompt or starting a new session. The command is not case-sensitive, so CLS, Cls, and cls work the same way.
You can run cls whenever the screen becomes cluttered. It is useful after commands that produce long results, such as ipconfig /all, dir /s, or a lengthy troubleshooting process. Clearing the screen changes what you see; it does not affect Windows settings, files, or running programs.
What Does the CLS Command Do?
cls is short for “clear screen.” It removes the text currently displayed in the Command Prompt window and returns the cursor to the top of the visible area. It is a CMD command, not a separate program you need to download or install.
For example, after running a few commands, your window might contain several pages of output. Typing cls clears that displayed content so the next result is easier to read. This can make it simpler to focus on a new task, capture a screenshot, or check the output from one command without older text in the way.
Clearing CMD is only a visual cleanup. The command does not undo previous commands, stop a process, or erase data from your computer. If a command is still running, cls will not cancel it. To interrupt many running commands, press Ctrl+C instead, but be aware that stopping a task may prevent it from finishing.
How to Clear CMD Before Running Another Command
You can clear the screen and then run another command in one line by joining the commands with &&. For example:
cls && ipconfig
CMD runs cls first. If that command succeeds, it runs ipconfig, displaying the network configuration on the cleared screen. This can be handy when you want to see fresh output without typing each command on a separate line.
You can use the same pattern with many other commands, such as:
-
cls && dirto clear the screen and show files in the current folder. -
cls && ping example.comto clear the screen before starting a ping test. -
cls && systeminfoto clear the screen before displaying system details.
Use && when you want the second command to run only if the first command succeeds. For simply clearing the screen, enter cls on its own.
How to Clear CMD with a Keyboard Shortcut
Command Prompt does not have one universal, built-in keyboard shortcut that works exactly like the cls command in every Windows setup. The dependable method is to type cls and press Enter. Some terminal applications or customized keyboard settings may provide a shortcut for clearing the screen, but shortcuts can vary by app and configuration.
If you use a keyboard shortcut in a terminal app, check its settings or command palette to see what action it performs. It may clear only the visible screen, or it may clear the scrollback buffer as well. When you need the standard CMD behavior, use cls.
Does CLS Delete Command History or Scrollback?
No. Typing cls clears the visible screen, but it does not delete your Command Prompt command history. During a CMD session, you can often review previously entered commands using the Up and Down arrow keys. The F7 key can also display a history menu in many Command Prompt configurations.
In some terminal windows, you may be able to scroll upward and see earlier output even after running cls. This depends on the terminal application and its scrollback behavior. The classic Command Prompt host and newer terminal apps do not necessarily handle saved output in the same way.
If you need to remove old scrollback from a terminal window, look for a separate “clear buffer” or similar option in that application. Be aware that this may erase output from the window, but it still does not securely erase files or remove a record from system logs. Clearing a screen is not a privacy or data-wiping tool.
How to Clear the Screen in PowerShell
PowerShell is a different command-line environment from Command Prompt, even though both can be opened in a Windows terminal window. In PowerShell, you can use Clear-Host to clear the visible screen. The shorter command cls is also available as an alias in standard PowerShell sessions.
For example, enter:
Clear-Host
Or use:
cls
In a standard PowerShell session, both commands provide a convenient way to clear the display. As with CMD, clearing the screen does not delete your files or stop a running command. If you are unsure which environment is open, check the prompt or window title, or enter $PSVersionTable in PowerShell to display version information.
How to Clear the Screen in Windows Terminal
Windows Terminal is an app that can host Command Prompt, PowerShell, and other command-line environments in tabs or panes. The correct command depends on the shell running in the active tab. If the tab is running CMD, type cls. If it is running PowerShell, use Clear-Host or its cls alias.
Windows Terminal may also offer actions for clearing the screen or clearing the buffer, depending on your version and settings. These actions are not always identical: clearing the screen removes the current display, while clearing the buffer can also remove scrollback that you could otherwise reach by scrolling. Use the Terminal command palette or keyboard shortcut settings to find the available action and confirm what it clears.
If you open the wrong shell by mistake, you do not need to close the terminal app. You can open a new tab with the shell you want, or type the appropriate clear command in the current tab. The app is the container; CMD and PowerShell are the command environments.
How to Clear CMD Automatically in a Batch File
You can add cls to a Windows batch file when you want the script to begin with a clean screen. A batch file is a text file containing commands that Windows runs in sequence. Put cls near the beginning of the file, before the output you want users to see.
For example, a simple batch file could contain:
@echo off
cls
echo Starting the task...
When the batch file runs in Command Prompt, cls clears the display before the message appears. The @echo off line hides the commands themselves as the batch file runs, which can make the screen easier to read. You can omit that line if you want CMD to show each command.
Use this approach for scripts that produce fresh status messages or menus. Avoid adding cls if users need to read output from earlier commands, because the screen content will be cleared before they can review it.
Common CLS Problems and Fixes
The cls command is simple, but a few issues can cause confusion:
-
“CLS is not recognized” appears: Check that you are using Command Prompt or a compatible shell, and make sure you typed
clscorrectly. In PowerShell, tryClear-Host. - The screen does not clear: Confirm that the command was entered at the prompt and that you pressed Enter. If a program is currently controlling the window, wait for it to finish or interrupt it if appropriate.
- Old text is still visible when you scroll: The terminal may retain scrollback. Use its separate clear-buffer option if you want to remove that saved display history.
-
You expected command history to disappear:
clsdoes not clear the session’s command history. It only cleans up the visible screen. - You expected a running task to stop: Use Ctrl+C for many command-line tasks, understanding that the task may be interrupted before it completes.
In most cases, the simplest fix is to identify which shell is active and use its clear command. For CMD, that is cls; for PowerShell, use Clear-Host or cls.
Conclusion
To clear CMD in Windows, type cls and press Enter. This built-in command clears the visible Command Prompt screen without closing the window or changing your files. It does not delete command history, erase scrollback in every terminal app, or stop a running process. For PowerShell, use Clear-Host or its cls alias. Once you know which shell is active, clearing a cluttered command-line screen takes only a moment.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.