The CHCP command in Windows Command Prompt is used to display or set the active console code page. Code pages are sets of characters that define how characters are represented in a text file. This command is particularly useful in scenarios involving multilingual text data where diverse character encodings are necessary for proper display and input in the console window.


The CHCP command follows this basic syntax:

CHCP [nnn]
  • nnn is the code page number that specifies the new active code page. If nnn is not provided, CHCP displays the currently active code page.


CHCP does not have additional flags or options. You only specify the code page number if you wish to change the current setting. Leaving the argument empty will default the function to displaying the current code page.


  1. Displaying the Current Code Page:

    C:\> CHCP
    Active code page: 437

    This command displays the current code page used by the console.

  2. Changing the Code Page to 65001 (UTF-8):

    C:\> CHCP 65001
    Active code page: 65001

    This is useful when you need to handle UTF-8 encoded text files in the command prompt.

  3. Switching between multiple code pages in a script:

    If a batch file processes files from different locales, you might need to switch code pages:

    CHCP 850 > nul
    REM Process a file encoded in Western European character set
    CHCP 437 > nul
    REM Switch back to the default code page

    This example shows how to temporarily change the code page to handle specific files, then revert back.

Common Issues

  • Error “Invalid code page”: Ensure the code page number is valid and available on your system.
  • Command does not affect the Windows GUI: CHCP changes only affect console applications. GUI applications do not respect this change.


The CHCP command can be integrated with other CMD commands to handle encoding issues in file operations or scripting tasks. For example, combining with FOR loop to process multiple files:

FOR %f IN (*.txt) DO (
    CHCP 65001
    TYPE %f
    CHCP 437

This script processes text files that are in UTF-8 encoding and then reverts to the default code page.

  • CMD: The command interpreter itself, where CHCP is executed.
  • Type: Displays the content of a text file. Using CHCP can change how content is interpreted or displayed.

For more detailed information on code pages and how they are used in Windows, you can refer to the Windows documentation on character sets.