Last Updated :
29 Nov, 2023
Color is an inbuilt command found inside the Windows Command Processor (cmd.exe), that is used for changing the colors of the console’s foreground and background. By default, the console has white foreground color and black background color (07 color code). The command is generally used either to personalize the aesthetics of the console window, or the make the colors more appropriate for Dim or Dark Displays (ex. TN panels). In this article, we will learn about the color command and will also take a look at the various uses it offers.
Description of the Command: Type the command – color /? in the Command Prompt. It sets the default console foreground and background colors.
COLOR [attr] attr - Specifies the color attribute of console output.
Color attributes are specified by two hex digits –
- First corresponds to the background.
- Second corresponds to the foreground.
Using the Command: The command takes in input 2 hexadecimal digits (2nd digit optional) where the first digit corresponds to the background color and the second digit corresponds to the foreground color.
Syntax:
Color (Background)(Foreground)
If the first digit is only provided, then only the foreground color changes. Each digit can have any of the values in hexadecimal codepoint (0 – f) where each one corresponds to a unique color. The digit-to-color correspondence is as follows –
0 = Black 8 = Gray 1 = Blue 9 = Light Blue 2 = Green A = Light Green 3 = Aqua B = Light Aqua 4 = Red C = Light Red 5 = Purple D = Light Purple 6 = Yellow E = Light Yellow 7 = White F = Bright White
Syntax:
Color 1F
It will produce bright White on Dark Blue. Any combination of the above set of digits could be used, except for the special case in which the foreground and the background color is the same (Ex. color FF or color 33). In that case, no color change occurs, and the value of %ERRORLEVEL% changes to 1. If the command is executed without providing any parameters, then the command will restore the color to which cmd.exe initially started as.
Changing Only The Foreground Color:
Syntax :
Color (Hex_digit)
- (Hex_digit) is a digit (or character) within the hexadecimal range, i.e. it should belong in the range 0-F. Example : We will change the foreground color to Yellow (6). Before :
After :
It is clear from the above images that after executing the command Color 6, the color of the foreground changes from white to yellow.
- Changing the Color of Background And Foreground: For changing the color of the foreground and the background of the console window, the color attributes are specified by 2 of the previously mentioned hex digits.
Syntax :
color (Back_Hex_digit)(Fore_hex_digit)
- Back_Hex_digit and Fore_hex_digit are hexadecimal digits used to determine the color of the background and foreground respectively. In the following example, we will change the background color to grey (7) and the foreground color to light green (a).
Before:
After:
Overview
The COLOR
command in Windows Command Prompt (CMD) is used to set the default foreground (text) and background colors of the console window. This command can enhance readability or personalize the look of the command-line interface. It is often used in scripts to denote different process stages or alert statuses visually.
Syntax
To use the COLOR
command, the syntax is:
COLOR [attribute]
The attribute
is a two-digit hexadecimal code where the first digit represents the background color and the second digit represents the text color.
If no attribute
is provided, the command resets the color to what was set when CMD was opened.
Options/Flags
The COLOR
command supports hexadecimal characters, each representing a different color:
0
Black1
Blue2
Green3
Aqua4
Red5
Purple6
Yellow7
White8
Gray9
Light BlueA
Light GreenB
Light AquaC
Light RedD
Light PurpleE
Light YellowF
Bright White
Leading zero is necessary if the color attribute should change only one color (foreground or background).
Default:
If the COLOR
command is run without arguments, it will revert to the default colors of the CMD window.
Examples
- Set text color to Light Red with Black background
COLOR 4C
- Reset to default color settings
COLOR
- Set background to Green and text color to Light Aqua
COLOR 2B
Common Issues
- Invalid color codes: Users must ensure the syntax contains only two valid hexadecimal characters. If invalid codes are used, CMD will ignore the command.
- Visibility issues: Some color combinations (e.g., blue text on a blue background) can lead to unreadable text. Always choose contrasting colors.
Integration
Script Usage
In batch files, COLOR
can be used to signal different sections of the script or signify success/warning/error states:
@echo off
COLOR 2E
echo Starting processing...
REM Processing steps here
COLOR 4E
echo WARNING: Low memory detected.
REM More processing steps here
COLOR A2
echo Process completed successfully.
Combined with ECHO
Used with ECHO
, COLOR
can highlight specific messages:
COLOR C
echo IMPORTANT: System will restart in 5 minutes!
MODE
: Adjusts properties of the console, including display settings.TITLE
: Sets the Command Prompt window title which can be visually informative along with color coding.
For more commands related to CMD customization, see Microsoft’s official CMD documentation.
This guide covers how to use the COLOR
command to customize the appearance of your CMD session dynamically and visually communicates the condition or status within scripts or during routine CMD interactions.
Загрузить PDF
Загрузить PDF
Вам надоело постоянно видеть стандартный белый текст на черном фоне в командной строке? Если да, тогда читайте дальше, чтобы узнать, как изменить цвет текста и фона.
-
-
-
Введите color z, чтобы получить список всех цветов и цифры или буквы, которые им соответствуют. Первые буква/цифра — это цвет фона, а вторая — цвет текста.
-
Например, введите color 6, чтобы получился желтый текст, color 4 для красного цвета, color A для изменения текста в светло-зеленую окраску и так далее.
-
Для изменения цвета текста, а также его фона, введите color ce, чтобы получился светло-желтый текст на светло-красном фоне, или любую другую комбинацию. Первая буква/цифра обозначает цвет фона, а вторая соотносится с цветом текста.
Реклама
-
-
-
-
-
Выберите свойства текста или фона и отредактируйте цветовые значения.
- Поэкспериментируйте с различными комбинациями!
-
Реклама
Список возможных расцветок
- 0 = Черный
- 1 = Синий
- 2 = Зеленый
- 3 = Аквамарин
- 4 = Красный
- 5 = Фиолетовый
- 6 = Желтый
- 7 = Белый
- 8 = Серый
- 9 = Светло-голубой
- A = Светло-зеленый
- В = Светлый аквамарин
- С = Светло-красный
- D = Светло-фиолетовый
- E = Светло-желтый
- F = Ярко-белый
Советы
- Будьте осторожны в правописании слова «color» и не введите по ошибке «colour». В противном случае изменения не сработают.
Реклама
Об этой статье
Эту страницу просматривали 104 072 раза.
Была ли эта статья полезной?
- SS64
- CMD
- How-to
Sets the default console foreground and background colours.
Syntax COLOR [background][foreground]
Colour attributes are specified by 2 of the following hex digits. There should be no space between the two color numbers.
Each digit can be
any of the following values:
0 = Black 1 = Blue 2 = Green 3 = Aqua 4 = Red 5 = Purple 6 = Yellow 7 = White 8 = Gray 9 = Light Blue A = Light Green B = Light Aqua C = Light Red D = Light Purple E = Light Yellow F = Bright White
The default terminal color is COLOR 07 – Black background (0) + white foreground (7).
If no argument is given, COLOR restores the colour to what it was when CMD.EXE started.
New default Colour schemes
In Windows 10 clean-install versions greater than build 16257 the default colour scheme has been changed to modernize the look of the Windows Console suitable for modern high-contrast LCD displays.
Samples of the new colors can be found on the ANSI color page, you can also display them with ColorTool.exe -c
If using ColorTool, you may want to tinker with the new values: «So up until very recently the console only supported 16 colours at a time. When the PowerShell team decided they wanted a very specific dark blue as the background colour, rather than altering the colour value for dark or light blue, they instead changed dark magenta to blue and used that as the background colour».
24 bit colors
The new W10 Console also adds full 24-bit colour support, this is primarily for Linux compatibility so the console properties page and the default Windows colour mappings still use just 16 colours, there is no plan to add additional console colours to the Win32 API.
To take advantage of the new colours use ColorTool.exe and install a theme, or use the VT100 sequences described here.
When the VT100 sequences are used with a version of the Windows Console that supports 24-bit colours they will display the desired RGB colour, older consoles will choose the nearest appropriate colour from the existing 16 colour table.
Colour values are assigned in the following order:
- The DefaultColor registry value.
- The CMD /T command line switch
- The current colour settings when cmd was launched.
The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute the COLOR command with a foreground and background colour that are the same.
The COLOR command will change the colour of all the text in the window. To change the colour of individual words/characters/paragraphs ANSI color escapes can be used. These are available in Windows versions greater than 1511.
Errorlevels
If the colour was successfully changed %ERRORLEVEL% = 0
Background and foreground colours are the same (will fail) = 1
e.g. COLOR 00
COLOR is an internal command.
If Command Extensions are disabled, the COLOR command will not function.
Examples
Set the colour to White on Blue:
color 17
“How much more black could this be?» and the answer is «None…none more black” ~ Spinal Tap
Related commands
CMD — Start a new CMD shell.
EXIT — Set a specific errorlevel.
How-to: Use ANSI colours in the terminal.
PowerShell: Write-Host — Write output to the screen (colour can be set for individual strings).
Colour codes — HTML/CSS.
Aaron Margosis — Change prompt colours for all Admin level prompts.
Paletton — Design colour themes.
Equivalent bash command (Linux): dircolors — Colour setup for ‘ls’
Copyright © 1999-2025 SS64.com
Some rights reserved
-
Batch Script or File
-
Change the Text Color of CMD Using Batch Script
-
Change the Text Color of CMD Every 1 Second
This article will first discuss the basic concept of a Batch script or Batch file. After introducing the Batch script, we will discuss the method for changing the text color of CMD every second using the Batch script.
Batch Script or File
A Batch script is a file containing different commands executed in a sequence. A Batch file or script stores different commands executed using the command line interpreter.
For example, the following is a Batch file hello.bat
:
@ECHO OFF
ECHO Hello World
The above Batch script contains two lines.
The first command, @ECHO OFF
, is used to hide all the commands, which are executed, from displaying on the command prompt itself. The ECHO Hello World
command displays Hello World
.
The output of the above batch script is as follows:
We can execute the .bat
file on the command line by typing the file name followed by the Enter key, as shown in the above figure. We can also run the batch file by double-clicking the file.
Batch File Extensions
A Batch script can be written in any typing or text editor with different file extensions, including .bat
, .cmd
, and .btm
.
- The
.bat
file extension is used for Batch scripts in DOS or Windows operating systems. - The
.cmd
file extension is used for Windows NT or OS/2. - The
btm
file extension is used in 4DOS or 4NT.
Change the Text Color of CMD Using Batch Script
In the Batch script, we can use a different color for text on cmd. The color
command can be used to change the text color.
For example, color [number]
is a color
command followed by the color number in hexadecimal. This hexadecimal number is like an alias to a specific color.
Consider the following script:
@echo off
color 06
echo Hello World
Output:
The above script contains a color 06
command, the hexadecimal number used as a code for the yellow color. Therefore, the said color command changes the text color of the command-line interface to yellow.
Following is the list of different available colors with their codes:
Change the Text Color of CMD Every 1 Second
We can use the color
and timeout
commands to change the text color of the cmd every unit of time. Consider the following script:
@echo off
set colors=0 1 2 3 4 5 6 7 8 9 A B C D E F
for %%n in (%colors%) do (
echo Hello World
color %%n
timeout 1 > null
)
The above script contains an array named colors
initialized with a sequence of codes for different colors, followed by a for
loop which iterates on the colors array and selects a color code in a variable n
. In the body of the for
loop, the script displays the Hello World
on screen and sleeps for 1 second using the timeout
command.
The color
command changes the text color in each iteration of the loop with different colors available in the colors
array.
The above script will change the text color of the output after each for
iteration. The outputs for some iterations of the loop are as follows:
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe