How to Clear the CMD Command Prompt Screen and Command History

The Windows Command Prompt (CMD) is a powerful tool, but after running multiple commands, the screen can fill up quickly — making it harder to read outputs and trace what you've actually done. Knowing how to clear CMD properly, and understanding the difference between clearing the display versus clearing the command history, saves real time and reduces confusion.

What "Clearing CMD" Actually Means

There are two distinct things people mean when they say they want to clear CMD:

  1. Clearing the screen — removing all visible text from the terminal window without affecting anything else.
  2. Clearing the command history — erasing the list of previously typed commands that you can cycle through using the arrow keys.

These are separate operations with separate commands. Conflating them is one of the most common sources of confusion for new CMD users.

How to Clear the CMD Screen 🖥️

The simplest and most widely used method is the cls command.

Using the cls Command

Type the following directly into the Command Prompt and press Enter:

cls 

That's it. The screen clears immediately. Every line of previous output disappears, and the cursor returns to a fresh prompt. The cls command works on all modern versions of Windows — from Windows 7 through Windows 11 — without any flags or additional syntax.

Important to know:cls only clears what's visible. It does not delete your command history. If you press the Up arrow key after running cls, your previous commands will still cycle through.

Keyboard Shortcut Alternative

Some users prefer a shortcut: pressing Ctrl + L in certain terminal emulators (like Windows Terminal) achieves the same effect as cls. In the classic CMD window, this shortcut doesn't work — but if you've upgraded to Windows Terminal, it functions as a screen-clear shortcut.

How to Clear CMD Command History

The command history in CMD is stored temporarily in memory for the current session. It allows you to press the Up and Down arrow keys to scroll through past commands — useful during a session, but sometimes something you'll want to wipe.

Using the doskey Command

The built-in tool for managing command history in CMD is doskey. To clear the history, run:

doskey /reinstall 

This reinitializes doskey and flushes the stored command history for the current session. After running it, pressing the Up arrow will no longer cycle through previous commands.

Combining Both Operations

If you want to both clear the screen and erase the history in one step, you can run them sequentially:

doskey /reinstall && cls 

The && operator runs the second command only after the first completes successfully — a clean, efficient way to handle both tasks at once.

Variables That Affect Your Approach

Not every CMD user is working in the same environment, and the right method depends on a few factors:

FactorImpact on Method
Windows versionCMD behavior is consistent, but Windows Terminal adds extra shortcut support
Terminal emulatorClassic CMD vs. Windows Terminal vs. PowerShell each behave differently
Session typeAdmin vs. standard sessions don't affect clearing, but may affect what was run
Scripting contextInside a .bat or .cmd script, cls clears screen mid-execution
Remote sessionsIn SSH or remote CMD sessions, cls may behave differently depending on the client

Clearing CMD Within a Batch Script

If you're writing a batch script (a .bat file) and want to clear the screen at a specific point during execution, you can drop cls directly into the script:

@echo off cls echo Starting process... 

The @echo off line suppresses command echoing, and cls wipes any prior output before your script's messages appear. This is standard practice for making scripts look clean and professional when they run.

What CMD Clearing Does Not Do

It's worth being direct about what these commands won't affect:

  • Files and folderscls and doskey /reinstall touch nothing on your file system.
  • Environment variables — set variables remain active for the session.
  • Running processes — clearing the screen doesn't interrupt anything executing in the background.
  • Persistent history — unlike PowerShell's PSReadLine history (which saves to a file), CMD history is session-only and not written to disk by default.

CMD vs. PowerShell: A Key Distinction

If you're using PowerShell instead of CMD, the commands differ slightly. PowerShell supports cls as an alias, but also accepts Clear-Host as the native command. PowerShell's history management is handled through Clear-History — a separate cmdlet that works differently from doskey. 🔄

This matters if your Windows environment opens PowerShell by default when you search for "Command Prompt" — something that varies by Windows version and system configuration.

How Your Setup Changes the Answer

The straightforward answer — type cls to clear the screen, doskey /reinstall to clear history — covers the majority of use cases on a standard Windows machine. But the specifics of your environment matter more than they might seem.

Whether you're in classic CMD or Windows Terminal, running commands manually or inside a script, on a local machine or a remote session, each scenario creates slightly different behavior. The commands themselves are consistent; what changes is how your particular setup responds to them and which approach fits your actual workflow.