This simple Python script allows users to convert UTF-8 text files into UTF-8 with BOM so that Windows Notepad (especially on Windows 11) correctly recognizes the encoding.
Many .txt
files created or saved as UTF-8 without a BOM may be misinterpreted by Notepad as UTF-16 or another encoding, causing display issues. This tool fixes that automatically with a user-friendly GUI.
- Opens a file picker to select your UTF-8
.txt
file. - Converts the file to UTF-8 with BOM.
- Saves the output in the same folder with
_utf8_bom
appended to the filename. - No command-line knowledge required — click and convert!
- Python 3.x
- No additional libraries needed (uses built-in
tkinter
andos
modules).tkinter
comes pre-installed with standard Python distributions.
- Download the script
utf8_add_bom.py
. - Double-click the script to launch the GUI.
- Select a UTF-8
.txt
file. - The script creates a new file with
_utf8_bom
appended to the name in the same folder. - Open the new file in Notepad — it should now be correctly recognized as UTF-8.
Example:
Original file:
example.txt
Converted file:
example_utf8_bom.txt
If you do not want to use the prebuilt .exe
provided in the GitHub release, you can create your own using PyInstaller:
- Install PyInstaller:
pip install pyinstaller
- Navigate to the folder containing
utf8_add_bom.py
and run:
pyinstaller --onefile --windowed utf8_add_bom.py
- After it finishes, you will find the standalone executable in the
dist
folder:
dist\utf8_add_bom.exe
- You can now run this
.exe
directly — no Python installation is required.
Optional flags:
- Add a custom icon:
pyinstaller --onefile --windowed --icon=myicon.ico utf8_add_bom.py
- Change the output folder:
pyinstaller --onefile --windowed --distpath ./output utf8_add_bom.py
- This script does not modify the original file.
- The output file is fully compatible with Windows Notepad, preventing mojibake caused by encoding misdetection.