chcp - Switch the Character Encoding

Maintained on

The chcp command checks and changes the code page (the character encoding) used by Command Prompt.

When output turns into garbled characters, it is almost always because the encoding of Command Prompt and the encoding of the data being read or written do not match. chcp lets you resolve that mismatch.

Basic syntax of chcp

chcp [<code_page_number>]

Without a number it shows the current code page; with a number it switches to that code page.

Check the current code page

Run it with no arguments.

chcp
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>chcp
Active code page: 437
C:\users\user>

The default is 437 on US English Windows and 932 (Shift_JIS family) on Japanese Windows.

Change the code page

Specify the number to switch to. Use 65001 for UTF-8.

chcp 65001
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>chcp 65001
Active code page: 65001
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

To go back, run chcp with the original number (for example chcp 437).

Common code pages

NumberNameUse
932Shift_JIS (Windows Japanese)Default on Japanese Windows
65001UTF-8UTF-8 files and output of web-style tools
437United States (OEM)Default on US English Windows
1252Western European (Windows)European-language text
Scope of the change

A change made with chcp applies only to that Command Prompt window (session). Closing the window or opening a new one returns to the default code page.

Fix garbled text

Display a UTF-8 file

Showing a UTF-8 text file with type under a non-UTF-8 code page produces garbled text. Switch with chcp 65001 first.

chcp 65001
type utf8.txt

When output is garbled

If the output of an external tool is garbled, set the code page to match the encoding the tool outputs: 65001 for UTF-8, 932 for Shift_JIS.

Switch temporarily in a batch file and restore

To use UTF-8 inside a batch file and put things back afterwards, save the current number first.

utf8.cmd
@echo off

for /f "tokens=2 delims=:" %%a in ('chcp') do set ORIG_CP=%%a
chcp 65001 >nul

type "%~dp0utf8.txt"

chcp %ORIG_CP% >nul

The wording of chcp output changes with the display language, but the number always follows a colon (:), so delims=: extracts it. Adding >nul hides the “Active code page” message.

When the batch file itself is saved as UTF-8

If a batch file (.cmd) containing non-ASCII text is itself saved as UTF-8, labels and goto may not be parsed correctly on some environments. For batch files you distribute, saving as the system’s legacy encoding (for example Shift_JIS in Japan) is safer. See the encoding article for details.

For the full picture, see the encoding article

How to choose a save format and how to switch the whole system to UTF-8 are covered in the related article below.

Practice questions

Practice Problem

Which command switches Command Prompt to UTF-8?

回答がサーバーに送信されることはありません
Practice Problem

Which statement about running chcp 65001 is correct?

回答がサーバーに送信されることはありません
#Command Prompt #Batch Files #Command Line #Commands #Garbled Text #Character Encoding