Terminal Color Codes Cheatsheet

Quick reference for terminal ANSI escape codes: text colors, background colors, formatting, and cursor control.

FeatureDescriptionExampleCategory
Black TextBlack foreground colorecho "\033[30mBlack Text\033[0m"Text Colors
Red TextRed foreground colorecho "\033[31mRed Text\033[0m"Text Colors
Green TextGreen foreground colorecho "\033[32mGreen Text\033[0m"Text Colors
Yellow TextYellow foreground colorecho "\033[33mYellow Text\033[0m"Text Colors
Blue TextBlue foreground colorecho "\033[34mBlue Text\033[0m"Text Colors
Magenta TextMagenta foreground colorecho "\033[35mMagenta Text\033[0m"Text Colors
Cyan TextCyan foreground colorecho "\033[36mCyan Text\033[0m"Text Colors
White TextWhite foreground colorecho "\033[37mWhite Text\033[0m"Text Colors
Black BackgroundBlack background colorecho "\033[40mBlack BG\033[0m"Background Colors
Red BackgroundRed background colorecho "\033[41mRed BG\033[0m"Background Colors
Green BackgroundGreen background colorecho "\033[42mGreen BG\033[0m"Background Colors
Yellow BackgroundYellow background colorecho "\033[43mYellow BG\033[0m"Background Colors
Blue BackgroundBlue background colorecho "\033[44mBlue BG\033[0m"Background Colors
Magenta BackgroundMagenta background colorecho "\033[45mMagenta BG\033[0m"Background Colors
Cyan BackgroundCyan background colorecho "\033[46mCyan BG\033[0m"Background Colors
White BackgroundWhite background colorecho "\033[47mWhite BG\033[0m"Background Colors
BoldBold/bright textecho "\033[1mBold Text\033[0m"Formatting
DimDim/faint textecho "\033[2mDim Text\033[0m"Formatting
ItalicItalic text (not widely supported)echo "\033[3mItalic Text\033[0m"Formatting
UnderlineUnderlined textecho "\033[4mUnderlined Text\033[0m"Formatting
BlinkBlinking textecho "\033[5mBlinking Text\033[0m"Formatting
ReverseReverse video (invert colors)echo "\033[7mReverse Text\033[0m"Formatting
HiddenHidden/concealed textecho "\033[8mHidden Text\033[0m"Formatting
StrikethroughStrikethrough textecho "\033[9mStrikethrough\033[0m"Formatting
Bright BlackBright black (gray) textecho "\033[90mBright Black\033[0m"Bright Colors
Bright RedBright red textecho "\033[91mBright Red\033[0m"Bright Colors
Bright GreenBright green textecho "\033[92mBright Green\033[0m"Bright Colors
Bright YellowBright yellow textecho "\033[93mBright Yellow\033[0m"Bright Colors
Bright BlueBright blue textecho "\033[94mBright Blue\033[0m"Bright Colors
Bright MagentaBright magenta textecho "\033[95mBright Magenta\033[0m"Bright Colors
Bright CyanBright cyan textecho "\033[96mBright Cyan\033[0m"Bright Colors
Bright WhiteBright white textecho "\033[97mBright White\033[0m"Bright Colors
Move UpMove cursor up N linesecho "\033[5A" # Move up 5 linesCursor Control
Move DownMove cursor down N linesecho "\033[3B" # Move down 3 linesCursor Control
Move RightMove cursor right N columnsecho "\033[4C" # Move right 4 colsCursor Control
Move LeftMove cursor left N columnsecho "\033[2D" # Move left 2 colsCursor Control
Set PositionSet cursor position (row;col)echo "\033[10;20H" # Row 10, Col 20Cursor Control
Clear ScreenClear entire screenecho "\033[2J"Cursor Control
Clear LineClear current lineecho "\033[2K"Cursor Control
Reset AllReset all formattingecho "\033[0m"Reset
CombinedCombine multiple codesecho "\033[1;31;44mBold Red on Blue\033[0m"Reset
RGB Color (256)256-color modeecho "\033[38;5;82mRGB Text\033[0m"Reset
True Color (RGB)True color 24-bitecho "\033[38;2;255;100;0mTrue Color\033[0m"Reset