I need to convert a text file to UTF-8 format via Windows command prompt. This needs to be done on another machine and I do not have rights to install software on that machine. I need something like:

c:\notepad   source-file target-file --encoding option

Is there a Windows command prompt utility which can do it?


I need to convert a text file to utf-8 format via windows command prompt

You can easily do this with PowerShell:

Get-Content .\test.txt | Set-Content -Encoding utf8 test-utf8.txt

Further Reading

  • Additionally, you need to switch to powershell in order to execute the command and then exit it to go back to windows command prompt. – user1107888 Jan 5 '17 at 16:09
  • Indeed. Or run it directly in a PowerShell shell. – DavidPostill Jan 5 '17 at 16:44
  • @DavidPostill any idea how we can convert more than one file i.e batch file processing with the same command line ? – vibs2006 Jan 28 '19 at 9:49
  • 1
    @vibs2006 Use a ForEach loop. See ForEach - PowerShell - SS64.com. – DavidPostill Jan 28 '19 at 18:32
  • Will this method convert to plain UTF-8 or UTF-8-BOM? – Cale Sweeney Oct 23 '19 at 22:28

Use iconv from GNUWin32 pack. It is much faster, especially if your files are about or more than 1 Gb.

"C:\Program Files (x86)\GnuWin32\bin\iconv.exe" -f cp1251 -t utf-8 source.txt > result.txt

Here is for each convert *.text file to *.sql file:

foreach ($file in get-ChildItem *.txt) {
    Echo $file.name
    Get-Content $file | Set-Content -Encoding utf8 ("$file.name" +".sql")
  • after run some sql file, sometime error, I decided to using linux with iconv command =)) – nobjta_9x_tq May 28 '19 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.