ANSI Escape Codes

code type mnemonic description example
ESC[0m SGR reset Sample
ESC[1m SGR bold Sample
ESC[1:2m SGR shadow
ESC[10m SGR default font Sample
ESC[100m SGR bright black background      
ESC[101m SGR bright red background      
ESC[102m SGR bright green background      
ESC[103m SGR bright yellow background      
ESC[104m SGR bright blue background      
ESC[105m SGR bright magenta background      
ESC[106m SGR bright cyan background      
ESC[107m SGR bright white background      
ESC[11m SGR alternate font 1 Sample
ESC[12m SGR alternate font 2 Sample
ESC[13m SGR alternate font 3 Sample
ESC[14m SGR alternate font 4 Sample
ESC[15m SGR alternate font 5 Sample
ESC[16m SGR alternate font 6 Sample
ESC[17m SGR alternate font 7 Sample
ESC[18m SGR alternate font 8 Sample
ESC[19m SGR alternate font 9 Sample
ESC[2m SGR dim Sample
ESC[20m SGR alternate font 10 Sample
ESC[21m SGR double underline Sample
ESC[22m SGR reset bold/dim Sample
ESC[23m SGR reset italic/alternate font Sample
ESC[24m SGR reset underline Sample
ESC[25m SGR reset blink Sample
ESC[27m SGR reset reversed video Sample
ESC[28m SGR reset conceal/overstrike Sample
ESC[29m SGR reset strike-through Sample
ESC[3m SGR italic Sample
ESC[30m SGR black foreground Sample
ESC[31m SGR red foreground Sample
ESC[32m SGR green foreground Sample
ESC[33m SGR yellow foreground Sample
ESC[34m SGR blue foreground Sample
ESC[35m SGR magenta foreground Sample
ESC[36m SGR cyan foreground Sample
ESC[37m SGR white foreground Sample
ESC[38;2;<r>;<g>;<b>m SGR set fg color (24-bit true color) Sample
ESC[38;5;<n>m SGR set fg color (256-color palette) Sample
ESC[39m SGR default fg color Sample
ESC[4m SGR underline Sample
ESC[4:0m SGR no underline
ESC[4:1m SGR single underline
ESC[4:2m SGR double underline
ESC[4:3m SGR curly underline
ESC[4:4m SGR dotted underline
ESC[4:5m SGR dashed underline
ESC[40m SGR black background      
ESC[41m SGR red background      
ESC[42m SGR green background      
ESC[43m SGR yellow background      
ESC[44m SGR blue background      
ESC[45m SGR magenta background      
ESC[46m SGR cyan background      
ESC[47m SGR white background      
ESC[48;2;<r>;<g>;<b>m SGR set bg color (24-bit true color)      
ESC[48;5;<n>m SGR set bg color (256-color palette)      
ESC[49m SGR default bg color
ESC[5m SGR slow blink Sample
ESC[51m SGR frame Sample
ESC[52m SGR encircle Sample
ESC[53m SGR overline Sample
ESC[54m SGR reset frame/encircle Sample
ESC[55m SGR reset overline Sample
ESC[58;2;<r>;<g>;<b>m SGR set underline color (24-bit true color) Sample
ESC[58;5;<n>m SGR set underline color (256-color palette) Sample
ESC[59m SGR reset underline color Sample
ESC[6m SGR rapid blink Sample
ESC[7m SGR reverse video Sample
ESC[73m SGR superscript Sample
ESC[74m SGR subscript Sample
ESC[75m SGR reset super/subscript Sample
ESC[8m SGR conceal Sample
ESC[8:7m SGR overstrike
ESC[9m SGR strike-through Sample
ESC[90m SGR bright black foreground Sample
ESC[91m SGR bright red foreground Sample
ESC[92m SGR bright green foreground Sample
ESC[93m SGR bright yellow foreground Sample
ESC[94m SGR bright blue foreground Sample
ESC[95m SGR bright magenta foreground Sample
ESC[96m SGR bright cyan foreground Sample
ESC[97m SGR bright white foreground Sample
ESC[<n> q CSI DECSCUSR set cursor style \u001b[2 q
ESC[ t CSI DECSWBV set warning bell volume
ESC[ u CSI DECSMBV set margin bell volume
ESC[!p CSI DECSTR soft terminal reset
ESC[<level>;<mode>"p CSI DECSCL select conformance level \u001b[64;1"p
ESC[<n>"q CSI DECSCA select character protection attribute \u001b[1"q
ESC[<n>@ CSI ICH insert characters \u001b[1@
ESC[<n>` CSI HPA horizontal position absolute \u001b[1`
ESC[$p CSI DECRQM request ANSI mode
ESC[$r CSI DECCARA change attributes in rectangular area
ESC[$t CSI DECRARA reverse attributes in rectangular area
ESC[$v CSI DECCRA copy rectangular area
ESC[$x CSI DECFRA fill rectangular area
ESC[$z CSI DECERA erase rectangular area
ESC[<n>a CSI HPR horizontal position relative \u001b[1a
ESC[<n>A CSI CUU move cursor up \u001b[1A
ESC[<n>b CSI REP repeat character \u001b[1b
ESC[<n>B CSI CUD move cursor down \u001b[1B
ESC[0c CSI DA device attributes: request primary device attributes
ESC[>0c CSI DA device attributes: request secondary device attributes
ESC[<n>C CSI CUF move cursor forward \u001b[1C
ESC[<n>d CSI VPA vertical position absolute \u001b[1d
ESC[<n>D CSI CUB move cursor back \u001b[1D
ESC[<n>e CSI VPR vertical position relative \u001b[1e
ESC[<n>E CSI CNL move cursor to next line \u001b[1E
ESC[<n>;<m>f CSI HVP horizontal vertical position \u001b[1;1f
ESC[<n>F CSI CPL move cursor to previous line \u001b[1F
ESC[0g CSI TBC tab clear: clear current column
ESC[3g CSI TBC tab clear: clear all tabs
ESC[<n>G CSI CHA move cursor character absolute \u001b[1G
ESC[4h CSI SM set mode: insert mode (IRM)
ESC[20h CSI SM set mode: automatic newline (LNM)
ESC[<n>;<m>H CSI CUP move cursor position \u001b[1;1H
ESC[0i CSI MC media copy (printer control): print screen
ESC[4i CSI MC media copy (printer control): turn off printer controller mode
ESC[5i CSI MC media copy (printer control): turn on printer controller mode
ESC[<n>I CSI CHT move cursor horizontal tabulation \u001b[1I
ESC[<n>j CSI HPB horizontal position backward \u001b[1j
ESC[0J CSI ED erase: from cursor to end of screen
ESC[1J CSI ED erase: from cursor to beginning of screen
ESC[2J CSI ED erase: entire screen
ESC[3J CSI ED erase: entire screen and clear scrollback buffer
ESC[<n>k CSI VPB vertical position backward \u001b[1k
ESC[0K CSI EL erase: from cursor to end of line
ESC[1K CSI EL erase: from cursor to beginning of line
ESC[2K CSI EL erase: entire line
ESC[4l CSI RM reset mode: replace mode (IRM)
ESC[20l CSI RM reset mode: normal linefeed (LNM)
ESC[<n>L CSI IL insert lines \u001b[1L
ESC[m CSI SGR select graphic rendition
ESC[<n>M CSI DL delete lines \u001b[1M
ESC[0n CSI DSR device status report: ready
ESC[5n CSI DSR device status report: status report
ESC[6n CSI DSR device status report: report cursor position
ESC[Rn CSI DSR device status report: report cursor position response
ESC[<n>P CSI DCH delete characters \u001b[1P
ESC[0q CSI DECLL load LEDs: turn off all LEDs
ESC[1q CSI DECLL load LEDs: turn on LED 1
ESC[2q CSI DECLL load LEDs: turn on LED 2
ESC[3q CSI DECLL load LEDs: turn on LED 3
ESC[4q CSI DECLL load LEDs: turn on LED 4
ESC[<t>;<b>r CSI DECSTBM set scrolling region \u001b[1;24r
ESC[s CSI SCP save cursor position
ESC[<n>S CSI SU scroll up (pan down) \u001b[1S
ESC[t CSI window manipulation
ESC[<n>T CSI SD scroll down (pan up) \u001b[1T
ESC[u CSI RCP restore cursor position
ESC[x CSI DECREQTPARM request terminal parameters
ESC[<n>X CSI ECH erase characters \u001b[1X
ESC[y CSI DECTSDT test diagnostic data
ESC[<n>Z CSI CBT cursor backward tabulation \u001b[1Z
ESC[?1h DEC DECCKM enable cursor key to application
ESC[?1l DEC DECCKM disable cursor key to application
ESC[?10h DEC enable show toolbar
ESC[?10l DEC disable show toolbar
ESC[?1000h DEC enable VT200 mouse reporting
ESC[?1000l DEC disable VT200 mouse reporting
ESC[?1001h DEC enable X11 mouse reporting
ESC[?1001l DEC disable X11 mouse reporting
ESC[?1002h DEC enable button-event mouse reporting
ESC[?1002l DEC disable button-event mouse reporting
ESC[?1003h DEC enable any-event mouse reporting
ESC[?1003l DEC disable any-event mouse reporting
ESC[?1004h DEC enable focus in/out events
ESC[?1004l DEC disable focus in/out events
ESC[?1005h DEC enable UTF-8 mouse mode
ESC[?1005l DEC disable UTF-8 mouse mode
ESC[?1006h DEC enable SGR mouse mode
ESC[?1006l DEC disable SGR mouse mode
ESC[?1007h DEC enable alternate scroll mode
ESC[?1007l DEC disable alternate scroll mode
ESC[?1010h DEC enable scroll to bottom on tty output
ESC[?1010l DEC disable scroll to bottom on tty output
ESC[?1011h DEC enable scroll to bottom on keypress
ESC[?1011l DEC disable scroll to bottom on keypress
ESC[?1014h DEC enable use CLIPBOARD for special paste
ESC[?1014l DEC disable use CLIPBOARD for special paste
ESC[?1015h DEC enable urxvt mouse mode
ESC[?1015l DEC disable urxvt mouse mode
ESC[?1016h DEC enable SGR mouse pixel mode
ESC[?1016l DEC disable SGR mouse pixel mode
ESC[?1016h DEC enable SGR mouse pixel mode
ESC[?1016l DEC disable SGR mouse pixel mode
ESC[?1021h DEC enable bold key sends DEL
ESC[?1021l DEC disable bold key sends DEL
ESC[?1022h DEC enable Sun function key mode
ESC[?1022l DEC disable Sun function key mode
ESC[?1023h DEC enable meta sends ESC
ESC[?1023l DEC disable meta sends ESC
ESC[?1034h DEC enable 8-bit meta key
ESC[?1034l DEC disable 8-bit meta key
ESC[?1035h DEC enable numeric keypad meta key
ESC[?1035l DEC disable numeric keypad meta key
ESC[?1036h DEC enable alternate key modifiers
ESC[?1036l DEC disable alternate key modifiers
ESC[?1037h DEC enable delete key to send DEL
ESC[?1037l DEC disable delete key to send DEL
ESC[?1038h DEC enable Alt key mode
ESC[?1038l DEC disable Alt key mode
ESC[?1039h DEC enable alternate backspace
ESC[?1039l DEC disable alternate backspace
ESC[?1039h DEC enable Alt sends ESC prefix
ESC[?1039l DEC disable Alt sends ESC prefix
ESC[?1040h DEC enable keep selection even if not highlighted
ESC[?1040l DEC disable keep selection even if not highlighted
ESC[?1041h DEC enable use CLIPBOARD selection
ESC[?1041l DEC disable use CLIPBOARD selection
ESC[?1042h DEC enable bell to urgent
ESC[?1042l DEC disable bell to urgent
ESC[?1043h DEC enable enable raising window on BEL
ESC[?1043l DEC disable enable raising window on BEL
ESC[?1044h DEC enable reuse most recent data to CLIPBOARD
ESC[?1044l DEC disable reuse most recent data to CLIPBOARD
ESC[?1045h DEC enable extended reverse-wraparound mode
ESC[?1045l DEC disable extended reverse-wraparound mode
ESC[?1046h DEC enable application cursor keys mode
ESC[?1046l DEC disable application cursor keys mode
ESC[?1047h DEC enable alternate screen mode
ESC[?1047l DEC disable alternate screen mode
ESC[?1048h DEC enable extended cursor mode
ESC[?1048l DEC disable extended cursor mode
ESC[?1049h DEC enable alternate screen buffer (with cursor save/restore)
ESC[?1049l DEC disable alternate screen buffer (with cursor save/restore)
ESC[?1050h DEC enable termcap/terminfo special keys
ESC[?1050l DEC disable termcap/terminfo special keys
ESC[?1051h DEC enable Sun function keys
ESC[?1051l DEC disable Sun function keys
ESC[?1052h DEC enable HP function keys
ESC[?1052l DEC disable HP function keys
ESC[?1053h DEC enable SCO function keys
ESC[?1053l DEC disable SCO function keys
ESC[?1055h DEC enable VT200 highlighting
ESC[?1055l DEC disable VT200 highlighting
ESC[?1056h DEC enable VT220 highlighting
ESC[?1056l DEC disable VT220 highlighting
ESC[?1057h DEC enable VT320 highlighting
ESC[?1057l DEC disable VT320 highlighting
ESC[?1060h DEC enable legacy xterm keys
ESC[?1060l DEC disable legacy xterm keys
ESC[?1061h DEC enable VT220 keyboard
ESC[?1061l DEC disable VT220 keyboard
ESC[?1062h DEC enable VT220 function keys
ESC[?1062l DEC disable VT220 function keys
ESC[?1070h DEC enable six-key function keys
ESC[?1070l DEC disable six-key function keys
ESC[?12h DEC enable blinking cursor
ESC[?12l DEC disable blinking cursor
ESC[?18h DEC DECPFF enable print feed form
ESC[?18l DEC DECPFF disable print feed form
ESC[?19h DEC DECPEX enable print extent
ESC[?19l DEC DECPEX disable print extent
ESC[?2h DEC DECANM enable ANSI mode
ESC[?2l DEC DECANM disable ANSI mode
ESC[?2004h DEC enable bracketed paste mode
ESC[?2004l DEC disable bracketed paste mode
ESC[?2026h DEC enable synchronized output mode
ESC[?2026l DEC disable synchronized output mode
ESC[?25h DEC DECTCEM enable show cursor
ESC[?25l DEC DECTCEM disable show cursor
ESC[?3h DEC DECCOLM enable number of columns to 132
ESC[?3l DEC DECCOLM disable number of columns to 132
ESC[?30h DEC enable show scrollbar
ESC[?30l DEC disable show scrollbar
ESC[?35h DEC enable enable font-shifting
ESC[?35l DEC disable enable font-shifting
ESC[?38h DEC DECTEK enable enter Tektronix mode
ESC[?38l DEC DECTEK disable enter Tektronix mode
ESC[?4h DEC DECSCLM enable smooth scrolling
ESC[?4l DEC DECSCLM disable smooth scrolling
ESC[?40h DEC enable allow 80->132 column mode
ESC[?40l DEC disable allow 80->132 column mode
ESC[?41h DEC enable more(1) fix
ESC[?41l DEC disable more(1) fix
ESC[?42h DEC DECNRCM enable national/multinational character mode
ESC[?42l DEC DECNRCM disable national/multinational character mode
ESC[?44h DEC enable margin bell
ESC[?44l DEC disable margin bell
ESC[?45h DEC enable reverse-wraparound mode
ESC[?45l DEC disable reverse-wraparound mode
ESC[?46h DEC enable start logging
ESC[?46l DEC disable start logging
ESC[?47h DEC enable alternate screen buffer
ESC[?47l DEC disable alternate screen buffer
ESC[?5h DEC DECSCNM enable screen mode to reverse video
ESC[?5l DEC DECSCNM disable screen mode to reverse video
ESC[?6h DEC DECOM enable origin mode to relative
ESC[?6l DEC DECOM disable origin mode to relative
ESC[?66h DEC DECNKM enable application keypad mode
ESC[?66l DEC DECNKM disable application keypad mode
ESC[?67h DEC enable backarrow sends backspace
ESC[?67l DEC disable backarrow sends backspace
ESC[?69h DEC DECVSSM enable vertical split screen mode
ESC[?69l DEC DECVSSM disable vertical split screen mode
ESC[?7h DEC DECAWM enable auto-wrap mode
ESC[?7l DEC DECAWM disable auto-wrap mode
ESC[?8h DEC DECARM enable auto-repeat keys
ESC[?8l DEC DECARM disable auto-repeat keys
ESC[?9h DEC DECINLM enable interlace mode
ESC[?9l DEC DECINLM disable interlace mode
ESC[?95h DEC enable do not clear screen when DECCOLM is set
ESC[?95l DEC disable do not clear screen when DECCOLM is set
ESC[<;<params>;<final> PRIVATE private sequence \u001b[<;1;h
ESC[=;<params>;<final> PRIVATE private sequence \u001b[=;1;c
ESC[>;<params>;<final> PRIVATE private sequence \u001b[>;0;c
ESC]0;<text>ST OSC OSC 0 set window title and icon name \u001b]0;title\u0007
ESC]1;<text>ST OSC OSC 1 set icon name \u001b]1;icon\u0007
ESC]2;<text>ST OSC OSC 2 set window title \u001b]2;title\u0007
ESC]3ST OSC OSC 3 set X property on top-level window
ESC]4;<n>;<color-spec>ST OSC OSC 4 set/read palette color \u001b]4;11;rgb:00/ff/00\u0007
ESC]5ST OSC OSC 5 change special color spec
ESC]6ST OSC OSC 6 enable special color
ESC]7;<url>ST OSC OSC 7 set current working directory \u001b]7;file://hostname/path\u0007
ESC]8;<params>;<url>ST OSC OSC 8 hyperlink \u001b]8;id=1;https://example.com\u0007
ESC]8ST OSC OSC 8 hyperlink (end)
ESC]9;<message>ST OSC OSC 9 send notification \u001b]9;hello there\u0007
ESC]10;<color-spec>ST OSC OSC 10 set/read text foreground color \u001b]10;rgb:ff/00/00\u0007
ESC]11;<color-spec>ST OSC OSC 11 set/read text background color \u001b]11;rgb:00/00/ff\u0007
ESC]12;<color-spec>ST OSC OSC 12 set/read text cursor color \u001b]12;rgb:00/ff/00\u0007
ESC]13ST OSC OSC 13 change mouse foreground color
ESC]14ST OSC OSC 14 change mouse background color
ESC]15ST OSC OSC 15 change Tektronix foreground color
ESC]16ST OSC OSC 16 change Tektronix background color
ESC]17ST OSC OSC 17 change highlight color
ESC]18ST OSC OSC 18 change Tektronix cursor color
ESC]19ST OSC OSC 19 change highlight foreground color
ESC]46ST OSC OSC 46 set log file
ESC]50ST OSC OSC 50 set font
ESC]51ST OSC OSC 51 reserved for emacs shell
ESC]52;<c>;<data>ST OSC OSC 52 manipulate clipboard \u001b]52;c;YmFzZTY0\u0007
ESC]104;<n>ST OSC OSC 104 reset palette color \u001b]104;11\u0007
ESC]105ST OSC OSC 105 reset special color spec
ESC]106ST OSC OSC 106 disable special color
ESC]110ST OSC OSC 110 reset dynamic color
ESC]111ST OSC OSC 111 reset dynamic color
ESC]112ST OSC OSC 112 reset dynamic color
ESC]113ST OSC OSC 113 reset dynamic color
ESC]114ST OSC OSC 114 reset dynamic color
ESC]115ST OSC OSC 115 reset dynamic color
ESC]116ST OSC OSC 116 reset dynamic color
ESC]117ST OSC OSC 117 reset dynamic color
ESC]118ST OSC OSC 118 reset dynamic color
ESC]119ST OSC OSC 119 reset dynamic color
ESC]133ST OSC OSC 133 FinalTerm shell integration
ESC]777;notify;<title>;<body>ST OSC OSC 777 send notification (rxvt-unicode) \u001b]777;notify;subject;hello\u0007
ESC]1000;<name>=<value>ST OSC OSC 1000 xterm modification \u001b]1000;resource=setting\u0007
ESC]1337ST OSC OSC 1337 iTerm2 shell integration
ESC F ESC S7C1T send 7-bit C1 controls
ESC G ESC S8C1T send 8-bit C1 controls
ESC L ESC set ANSI conformance level 1
ESC M ESC set ANSI conformance level 2
ESC N ESC set ANSI conformance level 3
ESC O ESC set ANSI conformance level 4
ESC_ ESC APC string
ESC(0 ESC SCS G0: select special graphics set
ESC(1 ESC SCS G0: select alternate ROM standard character set
ESC(2 ESC SCS G0: select alternate ROM special graphics set
ESC(A ESC SCS G0: select UK character set
ESC(B ESC SCS G0: select ASCII character set
ESC)0 ESC SCS G1: select special graphics set
ESC)1 ESC SCS G1: select alternate ROM standard character set
ESC)2 ESC SCS G1: select alternate ROM special graphics set
ESC)A ESC SCS G1: select UK character set
ESC)B ESC SCS G1: select ASCII character set
ESC[ ESC CSI - Control Sequence Introducer
ESC] ESC OSC - Operating System Command
ESC} ESC LS2R invoke G2 character set as GR
ESC*0 ESC SCS G2: select special graphics set
ESC*1 ESC SCS G2: select alternate ROM standard character set
ESC*2 ESC SCS G2: select alternate ROM special graphics set
ESC*A ESC SCS G2: select UK character set
ESC*B ESC SCS G2: select ASCII character set
ESC\ ESC ST string terminator
ESC#3 ESC DECDHL double-height line, top half
ESC#4 ESC DECDHL double-height line, bottom half
ESC#5 ESC DECSWL single-width, single-height characters
ESC#6 ESC DECDWL double-width, single-height characters
ESC#8 ESC DECALN screen alignment pattern
ESC%@ ESC select default character set
ESC%G ESC select UTF-8 character set
ESC^ ESC PM - Privacy Message
ESC+0 ESC SCS G3: select special graphics set
ESC+1 ESC SCS G3: select alternate ROM standard character set
ESC+2 ESC SCS G3: select alternate ROM special graphics set
ESC+A ESC SCS G3: select UK character set
ESC+B ESC SCS G3: select ASCII character set
ESC< ESC VT52 mode
ESC= ESC DECPAM application keypad
ESC> ESC DECPNM normal keypad
ESC| ESC LS3R invoke G3 character set as GR
ESC~ ESC LS1R invoke G1 character set as GR
ESC6 ESC DECBI back index
ESC7 ESC DECSC save cursor position
ESC7 ESC DECSC save cursor position
ESC8 ESC DECRC restore cursor position
ESC8 ESC DECRC restore cursor position
ESC9 ESC DECFI forward index
ESCc ESC RIS reset to initial state
ESCc ESC RIS reset to initial state
ESCD ESC IND index
ESCE ESC NEL next line
ESCH ESC HTS horizontal tab set
ESCl ESC memory lock
ESCM ESC RI reverse index
ESCM ESC RI reverse index
ESCn ESC LS2 invoke G2 character set
ESCo ESC LS3 invoke G3 character set
ESCP ESC DCS device control string
ESCX ESC SOS - Start of String
ESCZ ESC DECID identify device
ESCZ ESC DECID identify device
ESCP;<charset-data>{ST DCS DECDLD downloadable character set definition \u001bP;0;1;2;3;4;5;6;7{\u001b\\
ESCP;<termcap-data>+pST DCS set termcap/terminfo data \u001bP;xterm:co#80:li#24+p\u001b\\
ESCP;<capability>+qST DCS request termcap/terminfo string \u001bP;Co+q\u001b\\
ESCP;<key-definitions>|ST DCS DECUDK user-defined keys \u001bP;5/4,7/~~|\u001b\\
ESCP;<parameter>$pST DCS DECRQSS request \u001bP;"q$p\u001b\\
ESCP;<setting>$qST DCS DECRQSS request selection or setting \u001bP;m$q\u001b\\
ESCP;<state-data>$tST DCS restore presentation state \u001bP;presentation$t\u001b\\
ESCP;<format-data>$uST DCS restore format state \u001bP;format$u\u001b\\
ESC_;<command>ST STRING APC application program command \u001b_;custom application data\u001b\\
ESC^;<message>ST STRING PM privacy message \u001b^;private data content\u001b\\
ESCX;<data>ST STRING SOS start of string \u001bX;string sequence data\u001b\\

Something missing or incorrect? Feel free to report or fix.