If your Windows Command Prompt is cluttered with old commands and output, you can clear the screen in seconds. The quickest method is to type cls and press Enter. This guide explains how to clear CMD, what the command does, how to use it in scripts, and how to remove command history or scrollback when clearing the screen is not enough.
How Do I Clear CMD?
To clear the Command Prompt screen, enter the built-in cls command and press Enter:
cls
CMD clears the visible text from the console and displays a fresh prompt. You can then continue entering commands as usual. The command works in both Windows 10 and Windows 11, and in many older versions of Windows.
For example, your screen might show several commands and their results. Type cls at the prompt and press Enter, and that visible content disappears from the current screen. You do not need to install an app, open a settings menu, or run Command Prompt as an administrator.
Step-by-Step: Clear the Command Prompt Screen
- Open Command Prompt. You can search for “Command Prompt” or “cmd” in the Windows Start menu.
- Click the CMD window so it is active.
- Type
clsafter the prompt. - Press Enter.
The screen clears, and a new prompt appears. If you are working in a command-line program launched from CMD, you may need to exit that program first. For example, press Ctrl+C to stop a running command when appropriate, or type the program’s exit command, then enter cls at the regular CMD prompt.
What Does the CLS Command Do?
cls is short for “clear screen.” It is a command built into the Windows Command Prompt, so CMD recognizes it without needing to locate a separate program or file. Its purpose is to clear the console display, making it easier to focus on the next command or its results.
Clearing the screen is mainly a convenience. It does not undo commands, change files, stop services, or remove software. It also does not erase the effects of commands you ran earlier. For example, if a previous command created a folder, using cls will not delete that folder. It only cleans up what you see in the console.
The command is not case-sensitive, so cls, CLS, and Cls all work in Command Prompt. Typing the lowercase version is most common.
Can I Use a Keyboard Shortcut to Clear CMD?
In the classic Command Prompt window, cls is the reliable, built-in way to clear the screen. Some terminal apps and Windows Terminal configurations offer keyboard shortcuts for clearing visible text, but shortcuts can vary by app, settings, and version. If a shortcut you find online does not work in your window, use cls instead.
Be aware that common editing shortcuts are different from a clear-screen command. For example, Ctrl+C usually interrupts a running process or copies selected text, depending on the situation and console settings. It does not reliably clear CMD. Similarly, pressing Backspace only edits the current command line; it does not remove the output above it.
How to Clear CMD in Windows Terminal
Windows Terminal is an app that can host Command Prompt, PowerShell, and other shells. If your Windows Terminal tab is running Command Prompt, enter cls just as you would in the classic CMD window. The command clears the current CMD display.
Windows Terminal may retain previous output in its scrollback buffer, which means you might still be able to scroll upward after using cls. This depends on the terminal’s behavior and configuration. Clearing the screen and clearing the scrollback are not always the same thing. If your goal is to remove older output from view completely, check the Windows Terminal actions and settings for an option to clear the buffer or scrollback. The exact menu or shortcut can differ between versions.
Also check which shell is active in the tab. The prompt or tab title may indicate whether you are using Command Prompt or PowerShell. The commands for clearing the display differ between shells, so use the appropriate one for the active session.
Does CLS Delete CMD Command History?
No. The cls command clears the visible screen; it does not necessarily clear the commands you have entered during the current session. In a standard CMD session, you can often press the Up Arrow to recall earlier commands even after clearing the display.
To view commands stored in the current Command Prompt session, enter:
doskey /history
That command displays the session’s command history; it does not clear the screen or delete files. In classic Command Prompt, the Alt+F7 keyboard combination can clear the current session’s DOSKEY command history. Availability may depend on the console or terminal you are using. Closing the CMD session also ends its in-memory command history, unless a separate tool or configuration has been set up to save commands.
Command history is different from console output. If you want a clean-looking window, use cls. If you want to manage which commands can be recalled, use the history controls supported by your console. If your concern is a record saved elsewhere, such as a log file or monitoring system, clearing the display will not remove that record.
Can I Clear CMD Automatically in a Batch File?
Yes. Add cls to a Windows batch file wherever you want the Command Prompt screen cleared. For example:
@echo off
cls
echo Starting the task...
pause
In this example, cls runs before the message appears. The @echo off line hides the commands themselves from the screen, while echo displays a message. The pause command waits for a key press so the window does not move on immediately.
You can also place cls between sections of a batch script to remove previous output before showing new information. Use this carefully: clearing the screen can make it harder to review earlier messages or diagnose an error. If you need a record of results, consider writing important output to a log file instead of relying only on what appears in the console.
Why Is CLS Not Working?
If cls does not seem to work, check the following:
- Confirm that you are in Command Prompt. The command is built into CMD. PowerShell, Linux shells, and other command-line environments use different commands or behaviors.
- Wait for the current process to finish. If a program is still running, CMD may not be ready to accept a new command. Stop it safely or return to the prompt first.
-
Check the spelling. Enter
clswithout extra characters, then press Enter. - Check whether you can still scroll upward. In a terminal app, old output may remain in scrollback even after the visible screen is cleared.
- Try a new CMD window. Close the current session and open Command Prompt again to see whether the issue is specific to that window or shell.
If CMD displays an error such as “not recognized,” you may not be using Command Prompt. Look at the prompt or the application tab name and confirm the active shell before choosing a clear-screen command.
CMD, PowerShell, and Other Clear-Screen Commands
Different command-line environments use different commands to clear the display. In Command Prompt, use cls. In PowerShell, Clear-Host is the full command, and cls is also available as an alias in standard PowerShell sessions. In many Linux and macOS terminal shells, the usual command is clear.
These commands generally clear the terminal display, but they do not all work in every shell or terminal application. If clear returns an error in CMD, that is expected: classic Windows Command Prompt does not use it as its standard clear-screen command. Use cls instead.
Does Clearing CMD Erase Data or Make the Computer More Secure?
Clearing the CMD display does not erase files, browser data, system logs, or information stored by other applications. It is not a privacy or security cleanup method. The text may no longer be visible in the window, but the commands’ effects remain, and some terminal apps may retain output in scrollback.
If you are sharing your screen or preparing a clean console for a demonstration, cls is useful because it removes visible clutter. For sensitive information, avoid typing secrets directly into a command where they may appear on screen, in history, or in logs. Follow your organization’s security guidance for handling credentials and sensitive data.
Frequently Asked Questions
What is the fastest way to clear CMD? Type cls and press Enter. It is the quickest standard method in Windows Command Prompt.
Does CLS close Command Prompt? No. It clears the display, but the CMD session remains open and ready for another command.
Does CLS remove commands I already ran? No. It clears visible console text but does not reverse commands or reliably erase the session’s command history.
Can I clear CMD without typing? Some terminal apps support a clear-screen shortcut, but the key combination varies. Use cls when you want a dependable method that works in CMD.
Conclusion
To clear CMD, type cls at the Command Prompt and press Enter. This built-in command removes visible console text while leaving the CMD session open. It does not delete files, undo previous commands, or necessarily erase command history or terminal scrollback. For a clean screen, use cls; for history or scrollback, use the controls provided by your console or terminal app.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.