Programming Field

Cls - DOS/Command Prompt Reference

Clears all characters in the screen.

[MS-DOS] To use Cls, you must install ‘ANSI.SYS’ first (i.e. write something like ‘device=ANSI.SYS’ in Config.sys).

Syntax

cls

No options are available.

Details

In fact, Cls prints the string ‘<ESC>[2J’ (<ESC> is an escape character, its char code is 27(0x1B)). This string is one of the escape sequences, meaning ‘clear the screen’.

[MS-DOS, Windows 95/98/Me] The escape sequence will be output if Cls is executed with redirection ‘>’.

[Windows 95 and later] To clear the screen with Win32API, please see Microsoft Learn's ‘Clearing the Screen’.