How to Print Red Text in Terminal - ANSI Escape Code

Print red text in your terminal using ANSI escape code 31 for standard red and 91 for bright red. Code examples for Bash, Python, Node.js, Go, and C.

Standard Colors

Detailed Explanation

Printing Red Text in the Terminal

Red is one of the most commonly used ANSI colors, typically used for error messages, warnings, and important alerts. ANSI provides two shades: standard red (code 31) and bright red (code 91).

Standard Red (Code 31)

# Bash
echo -e "\033[31mError: File not found\033[0m"
# Python
print("\033[31mError: File not found\033[0m")
// Node.js
console.log("\x1b[31mError: File not found\x1b[0m");
// Go
fmt.Println("\033[31mError: File not found\033[0m")
// C
printf("\033[31mError: File not found\033[0m\n");

Bright Red (Code 91)

Bright red is more vivid and stands out more in most terminal themes:

echo -e "\033[91mCRITICAL: System failure\033[0m"

Red Background (Code 41)

For maximum emphasis, use a red background:

echo -e "\033[41;97m FATAL ERROR \033[0m"

Bold Red

Combining bold (code 1) with red creates an even more prominent effect:

echo -e "\033[1;31mBold red warning\033[0m"

Convention

Red is universally associated with errors and failures in terminal applications. Following this convention improves user experience because developers instinctively recognize red text as something requiring attention.

Use Case

Red text is the standard convention for displaying error messages, failed test results, critical warnings, and fatal errors in command-line applications. Build tools, test runners, linters, and deployment scripts all use red to indicate failure states. Using red consistently across your CLI tools helps users quickly identify problems.

Try It — ANSI Color Code Reference

Open full tool