ANSI escape code

ANSI X3.64 (ISO/IEC 6429)
Output of the system-monitor htop, an ncurses-application (which uses SGR and other ANSI/ISO control sequences).
Standard
  • ECMA-48
  • ISO/IEC 6429
  • FIPS 86
  • ANSI X3.64
  • JIS X 0211
ClassificationISO/IEC 2022 based control code and control sequence set
Other related encoding(s)
  • ITU T.61
  • ISO/IEC 8613-6 / ITU T.416

Other control function standards:
  • ITU T.101
  • JIS X 0207
  • ISO 6630
  • DIN 31626
  • ETS 300 706

ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as commands, rather than text to display verbatim.

ANSI sequences were introduced in the 1970s to replace vendor-specific sequences and became widespread in the computer equipment market by the early 1980s. Although hardware text terminals have become increasingly rare in the 21st century, the relevance of the ANSI standard persists because a great majority of terminal emulators and command consoles interpret at least a portion of the ANSI standard.