For developers, you can use the Blob API to generate and trigger a text file download directly from the browser without a server.
You can easily convert or save any HTML code as a text file using basic software already on your computer:
Use Notepad for Windows or TextEdit for Mac.
What is a TXT file and how to create a TXT file | Adobe Acrobat
To download HTML code as a text file, you can create a simple HTML link using the attribute or use a plain text editor to save your code manually. Method 1: Creating a Downloadable Link (HTML)
Name the file with a .txt extension (e.g., code_backup.txt ) instead of .html . Additional Tools and Services