How to make win32 console recognize ANSI/VT100 escape sequences? How to make win32 console recognize ANSI/VT100 escape sequences? windows windows

How to make win32 console recognize ANSI/VT100 escape sequences?


[UPDATE] For latest Windows 10 please read useful contribution by @brainslugs83, just below in the comments to this answer.

While for versions before Windows 10 Anniversary Update:

ANSI.SYS has a restriction that it can run only in the context of the MS-DOS sub-system under Windows 95-Vista.

Microsoft KB101875 explains how to enable ANSI.SYS in a command window, but it does not apply to Windows NT. According to the article: we all love colors, modern versions of Windows do not have this nice ANSI support.

Instead, Microsoft created a lot of functions, but this is far from your need to operate ANSI/VT100 escape sequence.

For a more detailed explanation, see the Wikipedia article:

ANSI.SYS also works in NT-derived systems for 16-bit legacy programs executing under the NTVDM.

The Win32 console does not natively support ANSI escape sequences at all. Software such as Ansicon can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.

So I think ANSICON by Jason Hood is your solution. It is written in C, supports 32-bit and 64-bit versions of Windows, and the source is available.

Also I found some other similar question or post which ultimately have been answered to use ANSICON:


Starting from Windows 10 TH2 (v1511), conhost.exe and cmd.exe support ANSI and VT100 Escape Sequences out of the box (although they have to be enabled).

See my answer over at superuser for more details.


For Python 2.7 the following script works for me fine with Windows 10 (v1607)

import osprint '\033[35m'+'color-test'+'\033[39m'+" test end"os.system('') #enable VT100 Escape Sequence for WINDOWS 10 Ver. 1607print '\033[35m'+'color-test'+'\033[39m'+" test end"

Result should be:

[35mcolor-test[39m test endcolor-test test end