chcp - Switch the Character Encoding
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
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

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

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

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

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
To go back, run chcp with the original number (for example chcp 437).
Common code pages
| Number | Name | Use |
|---|---|---|
932 | Shift_JIS (Windows Japanese) | Default on Japanese Windows |
65001 | UTF-8 | UTF-8 files and output of web-style tools |
437 | United States (OEM) | Default on US English Windows |
1252 | Western European (Windows) | European-language text |
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.
@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.
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.
How to choose a save format and how to switch the whole system to UTF-8 are covered in the related article below.