Win32::Console::ANSI - Perl extension to emulate ANSI console on Win32 system.


  use Win32::Console::ANSI;
  print "\e[1;34mThis text is bold blue.\e[0m\n";
  print "This text is normal.\n";
  print "\e[33;45;1mBold yellow on magenta.\e[0m\n";
  print "This text is normal.\n";

With the Term::ANSIColor module one increases the readability:

  use Win32::Console::ANSI;
  use Term::ANSIColor;
  print color 'bold blue';
  print "This text is bold blue.\n";
  print color 'reset';
  print "This text is normal.\n";
  print colored ("Bold yellow on magenta.\n", 'bold yellow on_magenta');
  print "This text is normal.\n";

And even more with Term::ANSIScreen:

  use Win32::Console::ANSI;
  use Term::ANSIScreen qw/:color :cursor :screen/;
  locate 1, 1; print "@ This is (1,1)", savepos;
  print locate(24,60), "@ This is (24,60)"; loadpos;
  print down(2), clline, "@ This is (3,16)\n";
  color 'black on white'; clline;
  print "This line is black on white.\n";
  print color 'reset'; print "This text is normal.\n";
  print colored ("This text is bold blue.\n", 'bold blue');
  print "This text is normal.\n";
  print colored ['bold blue'], "This text is bold blue.\n";
  print "This text is normal.\n";


Windows NT/2000/XP does not support ANSI escape sequences in Win32 Console applications. This module emulates an ANSI console for the script that uses it and also converts the characters from Windows code page to DOS code page (the so-called ANSI to OEM conversion). This conversion permits the display of the accented characters in the console like in the Windows- based editor used to type the script.

Escape sequences for Cursor Movement

Escape sequences for Display Edition

Escape sequences for Set Graphics Rendition

Escape sequences for Select Character Set

Extra escape sequences for Set Cursor Visibility

The two following escape sequences are not in the ANSI standard. These are private escape sequences introduced by DEC for the VT-300 series of video terminals.


Because the module exports no symbols into the callers namespace, it is necessary to import the names of the functions before using them.


Nothing by default; the function names and constants must be explicitly exported.

Export Tags:


Due to DOS-console limitations, the blink mode (text attributes 5 and 25) is not implemented.

If you use an integrated environment for developing your program you can see strange results on the console controlled by your IDE. The IDE catches and processes the output of your program so your program does not see a "real" console. In this case test your program in a separate console.


Win32::Console, Term::ANSIColor, Term::ANSIScreen.


J-L Morel <>

Home page:

Report bug:


Copyright (c) 2003-2015 J-L Morel. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.