This post explains how to change the default character encoding in Notepad (e.g., UTF-8 to ANSI) on Windows 10.
ANSI has been the default encoding in Notepad in earlier versions of Windows 10. Since Windows 10 version 1903, the default Notepad encoding is UTF-8.
When you launch notepad.exe
, the default encoding is shown in Notepad’s status bar in Windows 10 v1903 and higher.
When saving a file in Notepad in any version of Windows 10, you can choose one of these character encoding types:
- ANSI
- UTF-16 LE
- UTF-16 LE
- UTF-8 (default)
- UTF-8 with BOM
UTF-8 is preferred if you want to use non-ASCII characters like Č, Ć, Š, ä, ö, ü, ß
or symbols like → in your text file. Some of these accented characters will be lost if you save the file as ANSI. Notepad also warns you when you do so:
This file contains characters in Unicode format which will be lost if you save this file as an ANSI encoded text file. To keep the Unicode information, click Cancel below and then select one of the Unicode options from the Encoding drop down list. Continue?
Some users need ANSI to be the default
There are users who want to change Notepad’s default encoding from UTF-8 to ANSI. For example, VBS/WSH script coders may want ANSI as the default – because CScript.exe or WScript.exe can’t run UTF-8 encoded .vbs files.
Let’s see how to change Notepad’s default encoding to ANSI or another encoding in Windows 10.
Change the Default Character Encoding in Notepad
To set the default encoding in Notepad, you can use the Registry Editor.
- Right-click Start, click Run. Type
regedit.exe
and click OK. - Go to the following registry branch:
HKEY_CURRENT_USER\Software\Microsoft\Notepad
- From the Edit menu, click New → DWORD (32-bit) value
- Name the value as
iDefaultEncoding
- Double-click
iDefaultEncoding
and set its data to1
(for ANSI).
Here is the list of possible value data you can assign: 1 = ANSI 2 = UTF-16 LE 3 = UTF-16 BE 4 = UTF-8 BOM 5 = UTF-8
- Exit the Registry Editor.
- Open a new instance of Notepad. You’ll see that the default encoding has changed to
ANSI
— which is reflected in the status bar.
Note that the above registry setting applies only when you open a new Notepad instance by running Notepad.exe. If you open a text document previously saved in a different encoding, Notepad will open the file in the encoding specified in that file.
Despite the above registry modification, when you use the Desktop New menu (New → Text document), the New Text Document.txt fill will use UTF-8
anyway.
There is no workaround for that in Windows 10.
Force UTF-8 as default for New Text Documents (older versions of Windows)
This is the opposite of the earlier method – changing the New Text Document’s default encoding to UTF-8 from ANSI. This method is for older (than v1903) versions of Windows 10 and earlier Windows OS.
Clicking on Desktop → New → Text Document uses ANSI in earlier versions of Windows. However, using the template file method, we can force Windows to create the New Text Document in UTF-8. Follow these steps:
- Open Notepad as administrator.
- From the File menu, click Save.
- Choose
UTF-8
encoding from the dropdown list. - Save the file as
template.txt
inC:\Windows\ShellNew
. - Close Notepad.
- Launch the Registry Editor (
regedit.exe
) - Go to the following branch:
HKEY_CLASSES_ROOT\.txt\ShellNew
- Create a new String (REG_SZ) value named
FileName
- Double-click
FileName
and set its data to:template.txt
- Exit the Registry Editor.
We’ve now created an UTF8-encoded template file and referenced it in the registry. Windows will use it when you create a new text document.
- Right-click desktop → click New → Text Document.
- Double-click the newly created document.
If the above steps were executed correctly, you should see UTF-8 in the Notepad status bar.
[Note that the reverse (UTF-8 to ANSI) is not possible using the template method, as Notepad will open an ANSI-encoded file in UTF-8 mode anyway. You may look for Notepad alternatives in that case.]