ANSI color
also: ANSI escape codes, color codes, terminal colors, escape sequences
A standard system for adding colored and styled text to terminal output using special escape sequences. ANSI colors enable Linux applications to display text in different colors and text styles like bold or underline.
ANSI color codes are part of the ANSI escape sequence standard, allowing programs to control text formatting in terminals. They use sequences starting with the escape character followed by square brackets and parameters to specify colors and styles.
For example, the sequence \033[31m makes subsequent text red, while \033[0m resets formatting to default. Foreground colors range from 30–37 for standard colors, and 90–97 for bright variants. Background colors use 40–47 or 100–107.
Common tools like grep --color, ls --color, and many programming language libraries use ANSI colors to enhance readability. Most modern terminals support ANSI colors, making them a portable way to add visual distinction to command-line output.