How to open a .txt file
Plain text file · Text
A .txt file opens in any text editor on any device. If yours will not open, the file is either enormous, which crashes Notepad, or it uses an encoding your editor is reading wrongly.
What a .txt file actually is
Plain text is the simplest file there is: characters and nothing else, with no formatting, fonts or structure. It is the one format that has worked everywhere for fifty years.
The complications that remain are size and encoding. A log file can run to gigabytes, and the same bytes render as different characters depending on which encoding the editor assumes.
Why it will not open
Notepad struggles with very large files and will hang or refuse. And a UTF-8 file read as a legacy codepage turns every accented character into mojibake, which reads as corruption but is not.
Renaming it to an extension you can open will not help: changing the extension does not convert the file, it only changes what Windows tries to open it with.
Step by step
Windows
- 01For an ordinary file, double-click. Notepad opens it.
- 02For a large file, use VS Code or Notepad++, both of which handle hundreds of megabytes without freezing.
- 03If the characters look wrong, the encoding is being guessed incorrectly. In Notepad++ use Encoding, then Convert to UTF-8. In VS Code, click the encoding in the status bar and choose Reopen with Encoding.
- 04To see just the end of a huge log, run "Get-Content file.txt -Tail 100" in PowerShell rather than opening the whole thing.
macOS
- 01Double-click. TextEdit opens it.
- 02For large files, use VS Code, or "tail -n 100 file.txt" in Terminal.
- 03If characters look wrong, run "file -I file.txt" to see the encoding it actually uses.
What usually goes wrong
Windows and Unix disagree about line endings
A text file written on Linux or macOS can appear as one endless line in old Windows Notepad, because the line-ending convention differs. Modern Notepad handles both, and VS Code and Notepad++ always have.
Programs that open .txt
Our pick, in order. Every one links to the publisher's official download URL and the SHA-256 hash of the installer. Once you have downloaded it, you can check the file against our index before you run it.
If you end up downloading one of these from somewhere other than the publisher, what you can and cannot verify about that is worth two minutes.
- Sublime Text 4Sublime is a sophisticated cross-platform text editor for code, markup and prose.v4.0.0.420000 · 2 hashed installers92
- Notepad++Notepad++ is a free source code editor that supports several languages.v8.9.7 · 7 hashed installers95
- Microsoft Visual Studio CodeMicrosoft Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Microsoft Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.v1.132.0 · 4 hashed installers100
Also registers .txt in its manifest
Taken straight from publisher manifests. Some of these handle the format for a narrow purpose rather than as their main job.
Common questions
- How do I open a very large .txt file?
- Use VS Code or Notepad++, which handle files hundreds of megabytes in size. Notepad hangs on large files. To read just the end of a log, "Get-Content file.txt -Tail 100" in PowerShell avoids loading it all.
- Why does my text file show strange characters?
- The file is UTF-8 but is being read as a legacy codepage. Reopen it specifying UTF-8: in Notepad++ via the Encoding menu, in VS Code by clicking the encoding in the status bar.