Convert file Encoding in the Linux Terminal (e.g., for Plex Subtitles)

If you’re using Plex and run into subtitle issues, it might be due to incorrect text encoding. Plex only supports UTF-8 encoded subtitle files. Luckily, converting file encodings in Linux is simple using iconv, a tool that comes preinstalled on most modern distributions.

Example: Convert from Windows-1251 to UTF-8

iconv -f WINDOWS-1251 -t UTF-8 sourcefile.srt > newfile.srt

Flags explained:

  • --from-code, -f: Specifies the encoding of the source file.
  • --to-code, -t: Specifies the desired encoding for the output file.

How to Detect a file’s Encoding

Before converting, you can check the current encoding of a file using uchardet:

uchardet sourcefile.srt

This tool will output the most likely character encoding of the file, which you can then use with iconv.