The simplest answer: your operating system comes with one built in
Every computer ships with a program that opens .txt files — plain text documents with no formatting. On Windows, that program is Notepad. On Mac, it's TextEdit. On Linux, it's usually gedit or nano depending on your distribution. You don't need to download anything. Right-click any .txt file, select "Open with," and choose the default option.
But "built-in" doesn't mean "best for what you're doing." A .txt file opened in Notepad looks identical to one opened in Microsoft Word, but Word adds invisible formatting codes that can corrupt the file if you're not careful. If you're editing code, configuration files, or anything that needs to stay plain text, the choice of program matters.
Key Takeaways
- Windows includes Notepad, Mac includes TextEdit, and Linux includes gedit or nano — all free and already on your computer.
- Word processors like Microsoft Word and Google Docs can open .txt files but may add hidden formatting that breaks code or configuration files.
- Code editors like Visual Studio Code, Sublime Text, and Notepad++ are free or low-cost and designed to keep files as plain text while adding features like syntax highlighting and line numbers.
- The right choice depends on what's in the file: simple notes work fine in Notepad, but code and configuration files need a text editor or code editor.
Built-in programs that come with your operating system
Notepad (Windows) opens any .txt file instantly with no setup. It shows the raw text exactly as it is, with no hidden formatting. The trade-off is that it has almost no features — no line numbers, no search-and-replace, no syntax highlighting for code. If you're reading a simple text file or jotting down notes, Notepad is fine. If you're editing a configuration file or debugging code, you'll notice the missing features quickly.
TextEdit (Mac) works the same way, but has one important quirk: it defaults to rich text mode, which adds formatting. When you open a .txt file, TextEdit usually switches to plain text automatically, but if you're creating a new file, you need to go to Format menu and select "Make Plain Text" before saving. Otherwise you'll create a .rtf file instead of .txt.
gedit (Linux, GNOME desktop) and nano (Linux, command line) both open .txt files as plain text. gedit has a graphical window with menus; nano runs in the terminal. Both are lightweight and reliable for simple editing tasks.
Word processors: they work, but they're not ideal
Microsoft Word, Google Docs, and Apple Pages can all open .txt files. They display the text correctly and let you edit it. The problem is what happens when you save: these programs are designed to add formatting — fonts, colors, margins, styles — and they embed that information in the file even if you don't see it on screen. If the .txt file contains code, a configuration file, or anything that needs to stay as pure text, those hidden codes can break it.
If you open a .txt file in Word and save it without changing the file type, Word will usually keep it as .txt, but the file may contain invisible formatting characters. Some programs that read the file later — like a web server reading a configuration file — will choke on those characters. For simple documents you're just reading or lightly editing, Word works fine. For anything technical, avoid it.
Text editors: more features, still plain text
Notepad++ (Windows only) is free and adds features Notepad lacks: line numbers, find-and-replace, syntax highlighting for code, and tabs for multiple files. It keeps files as plain text — no hidden formatting — and is popular with people who edit code or configuration files regularly. Download it from notepad-plus-plus.org.
Visual Studio Code (Windows, Mac, Linux) is free and more powerful than Notepad++. It's designed for writing code but works perfectly for any .txt file. It shows line numbers, highlights syntax for dozens of languages, lets you search across multiple files, and has extensions for almost any task. The learning curve is slightly steeper, but most people pick it up in an hour. Download from code.visualstudio.com.
Sublime Text (Windows, Mac, Linux) is paid ($99 one-time, with a free trial that never expires) and sits between Notepad++ and Visual Studio Code in complexity. It's fast, reliable, and popular with professional writers and developers. If you edit text files regularly, the cost is reasonable.
Choosing the right program for what you're doing
If you're reading a .txt file someone sent you or jotting down quick notes, use whatever came with your computer — Notepad, TextEdit, or gedit. It's instant and requires no decisions.
If you're editing code, configuration files, or anything that other programs will read later, use a text editor or code editor. Notepad++ and Visual Studio Code are both free and won't add hidden formatting. Visual Studio Code is more powerful but takes longer to learn; Notepad++ is simpler but Windows-only.
If you're writing long documents with multiple people, use Word or Google Docs — but save as .docx or .odt, not .txt. Those formats are designed to hold formatting. Trying to keep a formatted document as plain text defeats the purpose of both.
How to set a default program for .txt files
Windows: Right-click any .txt file, select "Open with," then "Choose another app." Find the program you want, check the box that says "Always use this app to open .txt files," and click Open. From then on, double-clicking any .txt file will open it in that program.
Mac: Right-click a .txt file, select "Open With," then choose the program. To make it the default, select the file, press Command+I to open Get Info, scroll to "Open With," choose your program, and click "Change All." Confirm when prompted.
Linux: Right-click a .txt file, select "Properties" or "Open With," choose your program, and look for a checkbox to set it as default. The exact steps vary by desktop environment (GNOME, KDE, etc.), but the principle is the same.
File type confusion: when a .txt file isn't actually .txt
Sometimes a file has a .txt extension but contains code or data meant for a specific program. A .csv file (comma-separated values) is technically plain text, but it's meant to be opened in a spreadsheet program like Excel or Google Sheets, not a text editor. A .json or .xml file is plain text but meant for code editors or specialized tools.
If you open one of these files in Notepad and it looks like gibberish or structured data rather than readable text, that's normal. The file is still plain text — you're just using the wrong tool to view it. Check what program created the file or what program the instructions say to use. The .txt extension is just a label; the content determines what program makes sense.
Frequently Asked Questions
Can I open a .txt file in Microsoft Word?
Yes. Word can open .txt files without any problem. The risk is that if you edit and save the file in Word, it may add hidden formatting codes that break the file if another program reads it later. For simple reading or light editing of notes, it's fine. For code or configuration files, use a text editor instead.
Why does my .txt file look weird when I open it?
The file itself is fine — you're probably using the wrong program. If it contains code or data (JSON, XML, CSV), open it in a code editor or the program that created it, not Notepad. If it contains special characters or symbols, the program you're using may not display them correctly; try a different text editor.
Is Notepad++ better than Visual Studio Code?
Notepad++ is simpler and faster to learn; Visual Studio Code is more powerful and works on Windows, Mac, and Linux. For editing plain text files, both work equally well. If you edit code regularly, Visual Studio Code's extra features pay off. If you just need a lightweight upgrade from Notepad, Notepad++ is enough.
What's the difference between a .txt file and a .doc file?
.txt is plain text with no formatting — just letters, numbers, and symbols. .doc is Microsoft Word's format and contains formatting information (fonts, colors, margins) embedded in the file. .txt files are smaller, simpler, and work on any device; .doc files preserve layout and style but only open correctly in Word or compatible programs.
Do I need to download a program to open .txt files?
No. Every computer comes with a program that opens .txt files. On Windows it's Notepad, on Mac it's TextEdit, on Linux it's gedit or nano. You only need to download something if you want extra features like syntax highlighting or line numbers.