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.

1 thought on “Convert file Encoding in the Linux Terminal (e.g., for Plex Subtitles)”

  1. iconv has saved me a few times when subtitles wouldn’t display properly—didn’t realize it was usually an encoding issue until recently. Also, thanks for the tip on uchardet; I was using `file -i` but it’s not always reliable.

Leave a Reply

Your email address will not be published. Required fields are marked *