TextEdit turned HTML file into RTF while open - how to undo?
TextEdit is a plain text editor it you first set the preferences for Format to "Plain text" before opening the file.

Unfortunately Auto-Save has it drawbacks and if you do not have a proper backup of the file I'd say you're out of luck since the file was stored on a volume that could not store versions of the file.