How to Clear Command Prompt (CLS & More)
In this article
To clear the Command Prompt window, type cls and press Enter. That's the built-in command that wipes all previous text from the screen, giving you a clean slate. If you want to clear the entire command history or reset the prompt's environment, there are a few extra steps—but cls is the core answer.
What You'll Need
- A Windows PC (any version from Windows 7 to Windows 11).
- Access to the Command Prompt—either a standard user or administrator window (the steps are the same for both).
- No special tools or downloads are required; everything is built into Windows.
Step-by-Step
- Open Command Prompt. Press Win + R, type
cmd, and press Enter. Alternatively, search for “Command Prompt” in the Start menu and click it. - Type the clear command. At the prompt, type
cls(lowercase or uppercase doesn’t matter) and press Enter. The screen will instantly clear, leaving only the prompt line (e.g.,C:\Users\YourName>) at the top. - Use the shortcut (optional). If you prefer not to type, you can also press Ctrl + L in most Windows terminal applications (including the classic Command Prompt in Windows 10 and 11). This does the same thing as
cls. - Clear the command history (optional). The
clscommand only clears the visible screen, not the history of commands you’ve typed. To clear the history so you can’t scroll back through previous commands, press Alt + F7 (this works in the classic console). If you’re using Windows Terminal (the newer app), you can clear the history by clicking the down arrow next to the tab and selecting “Clear History” or by using the commandClear-Historyin PowerShell, but in classic Command Prompt, Alt + F7 is the shortcut. - Exit and reopen (nuclear option). If you want a completely fresh session—clearing the screen, history, and any temporary environment variables—just type
exitand press Enter, then open Command Prompt again. This is the most thorough way to “clear” everything.
Common Mistakes
- Typing “clear” instead of “cls”. On Linux or macOS, the command is
clear, but in Windows Command Prompt, it’scls. Typingclearwill give you an error: “'clear' is not recognized as an internal or external command.” - Forgetting to press Enter. Typing
clswithout pressing Enter does nothing—the command won’t execute until you hit Enter. - Using
clsin PowerShell. In PowerShell,clsis an alias forClear-Host, so it works, but if you typeclearit also works because it’s an alias. However, in classic Command Prompt, onlyclsworks. - Expecting
clsto clear history. As mentioned, it only clears the visible screen. If you press the up arrow, you’ll still see previous commands.
Tips
- Use
clsin batch files. If you write a batch script, addingclsat the beginning will give a clean output every time the script runs. - Customize the prompt after clearing. After clearing, you can set a custom prompt by typing
prompt $P$G(the default) or something likeprompt MyPC>to personalize it. - Clear the screen in Windows Terminal. If you use Windows Terminal (the modern app),
clsworks the same way, and you can also use Ctrl + Shift + W to close the tab, but that’s not the same as clearing. - Use
clsto reduce clutter. When running long commands or scripts that produce lots of output, clearing the screen before each run helps you focus on the latest results.
Troubleshooting
If cls doesn’t work as expected, try these steps in order:
- Check that you’re in Command Prompt, not PowerShell. Both accept
cls, but if you’re in PowerShell and it fails, tryClear-Hostinstead. To see which shell you’re in, look at the title bar—it usually says “Command Prompt” or “Windows PowerShell.” - Restart Command Prompt. Close the window and reopen it. Sometimes the console gets into a weird state, and a fresh start fixes it.
- Run as administrator. If you’re having issues with commands not responding, right-click Command Prompt and select “Run as administrator.” This gives full access and often resolves glitches.
- Update Windows Terminal. If you’re using Windows Terminal and
clsisn’t clearing, check for updates in the Microsoft Store, as older versions had bugs. - If the screen still shows text after typing
cls, it might be a display issue. Try resizing the window or minimizing and restoring it. If that fails, restart your computer—rarely, the console driver can hang.
Frequently Asked Questions
Does cls delete any files or data?
No. cls only clears the text on the screen. It does not affect files, folders, or any data on your system.
What’s the difference between cls and exit?
cls clears the screen but keeps the session open. exit closes the Command Prompt window entirely, ending the session. If you want a clean slate without closing, use cls.
Can I clear the screen in PowerShell with cls?
Yes, cls is an alias for Clear-Host in PowerShell, so it works exactly the same way.
Why does my Command Prompt show “The system cannot find the path specified” after clearing?
That error is unrelated to cls. It usually means a command you ran earlier referenced a directory that no longer exists. Check the current directory by typing cd and verify the path is correct.
Is there a way to clear the screen automatically after each command?
No built-in option does that automatically. You could create a batch file that runs cls after each command, but that’s not practical. Instead, just press Ctrl + L whenever you need a clean screen.
Does cls work in Windows 11?
Yes, cls works in all modern Windows versions, including Windows 11, whether you use the classic console or Windows Terminal.