What is a .TXT file?
A .TXT file generally means a text file. This is an arrangement of textual content without having any fonts, formatting, or pictures embedded within it, i.e., a file where the formatting is dictated by the text itself rather than being defined through a specific software or other means.
A variety of conventions uses .TXT extension. The majority are just some text file containing either plain text or something similar, however this convention includes README, NFO and log files; text file exported from databases, financial accounting programs, test equipment or spreadsheet applications; files in UTF-8 saved with a BOM; sometimes - mislabeled files that should actually have RTF or PDF extension. Delimiters in a .TXT delimited files can be tabs, commas, semicolons, a fixed amount of characters for each item, or pipes. This means the filename extension can tell nothing about the content structure. NFO-style documents are frequently formatted by means of ASCII or extended ASCII characters with proper displaying of this information requiring a monospace font along with legacy code pages, namely CP437 and Windows-1252.
Open a file with a text editor to find what kind of document it is. If you see readable content - this is .TXT, everything else - is not.
How to open a .TXT file
Open a .TXT file on Windows
- 1 Go to the folder with your file in File Explorer. Usually, downloaded files end up in Downloads.
- 2 Double-click your .TXT file if you have an app for .txt files on your computer. In case it does not open, move on to step three.
- 3 Right-click your .TXT file -> select .
- 4 Choose Microsoft Notepad in the list (Windows 11: choose Always). For Windows 10 -> put a check on "Always use this app to open .txt files" and click OK.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Windows
- Microsoft Notepad free
- Microsoft Word paid
- Vim open-source
- Visual Studio Code free
- Notepad++ open-source
- Sublime Text paid
- LibreOffice Writer open-source
- Microsoft Excel paid
Open a .TXT file on macOS
- 1 In the Finder app, locate your .TXT file.
- 2 Just double-click your .TXT file in order to automatically launch the program which is connected with it.
- 3 Need another app on your Mac? Control-click the file (or right-click with a mouse). In the pop-up menu select .
- 4 If it isn't in the list, choose and find the application manually.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for macOS
- Microsoft Word paid
- Apple TextEdit free
- GNU nano open-source
- Vim open-source
- Visual Studio Code free
- Sublime Text paid
- LibreOffice Writer open-source
- Textastic Code Editor paid
Open a .TXT file on Linux
- 1 Launch your file manager. Depending on the desktop it may be named Files (GNOME), Dolphin (KDE Plasma), Nemo (Cinnamon) or Thunar (Xfce).
- 2 Double-click the file.
- 3 Or choose another program by right-clicking the file -> .
- 4 Install GNOME Text Editor (if it is not installed on your computer) from the software centre, repository or Flathub.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Linux
- GNU nano open-source
- Vim open-source
- Visual Studio Code free
- Sublime Text paid
- LibreOffice Writer open-source
- LibreOffice Calc open-source
Open a .TXT file on Android
- 1 Launch Files or another file management app.
- 2 In Downloads, find the .TXT file and open it by tapping.
- 3 A list of apps capable of opening the file will be shown. Tap QuickEdit Text Editor and press Always to permanently connect the file type with this app.
- 4 No apps able to open this file? Download QuickEdit Text Editor from the Google Play Store.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Android
- Microsoft Word paid
- Google Docs free
- QuickEdit Text Editor freemium
- Microsoft Excel paid
- Adobe Acrobat Reader free
Open a .TXT file on iPhone / iPad
- 1 Use the Files app and go to On My iPhone, iCloud Drive or Downloads.
- 2 Tap the .TXT file you want to open.
- 3 If the file can be opened by a built-in iOS app (supported format), it opens automatically.
- 4 Touch and hold the file to get the context menu -> choose -> select a suitable app from the list of apps.
- 5 If there is no such option, download the app first from the App Store and then tap the document again.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for iPhone / iPad
- Microsoft Word paid
- Google Docs free
- Textastic Code Editor paid
- Microsoft Excel paid
- Adobe Acrobat Reader free
Open a .TXT file online
- 1 Move to the online viewer at the top of this page.
- 2 Drag the file there or select it, and its contents will appear in your browser tab. The file is not uploaded.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Online
- Microsoft Word paid
- Visual Studio Code free
- Google Docs free
- Microsoft Excel paid
More details about opening .TXT files
The Windows application Microsoft Notepad, allows opening of common .txt, editing directly and current encodings, like UTF-8, UTF-8 with BOM.
The files for the large logs, code, text in general requiring search and syntax highlighting should be opened via Notepad++, Visual Studio Code or Sublime Text.
Tabular data within the .TXT file will work with Excel (by Microsoft) and LibreOffice Calc while Microsoft Word (Office) or LibreOffice Writer will do formatting.
TextEdit works on Macintosh operating systems and is responsible for both opening .TXT and working with its contents through switching to either plain text or to the richer format.
BBEdit, Visual Studio Code and Textastic can handle more advanced actions regarding encoding, large file management and handling of line ending issues.
On Linux, gedit, Kate, GNOME Text editor, nano, Vim, Emacs, Visual Studio Code, less, and cat can work with the pure text file.
Various vendors' file-viewer applications are on Android OS as an option to use together with other apps for plain files, such as QuickEdit, Google Docs, Microsoft Word and file managers that are viewing the preview of such files.
On iOS, iPhones and iPads have a possibility of using Files app, preview window; Notes to view/import/share such a file, as well as Textastic, Google Docs and Microsoft Word to view/edit the .txt file that lies in the iCloud Drive folder among others. In addition, browsers display a text file directly, while plain text file will be handled as well in the office online applications as well GitHub, GitLab and paste sites.
In case you encounter troubles with double clicking on a file to view the content, you can try to change its application in Open With and make sure the file association was returned to its original text editing application.
The files that start with 7B 5C 72 74 66 are associated with RTF file and those, which start with 25 50 44 46 2D - with PDF file.
For the file that is divided by delimiters, please import such a file in Excel or LibreOffice Calc, Google Sheets and set delimiter, encoding, decimal and text qualifier.
Technical details
There is no mandatory structure within a .TXT file. It consists of plain text with no required header/footer, no required internal table of contents, nor any mandatory features like compression or layout within a container. Usually it is only raw sequence of bytes viewed as characters within the respective application. Its media type can be specified as the following string - text/plain. It also may be assigned charset value such as charset=utf-8, charset=us-ascii and charset=windows-1252, although many local files don't use charset at all. Examples of common character set are UTF-8, UTF-8 BOM (EF BB BF), UTF-16LE (FF FE), UTF-16BE (FE FF), US-ASCII, ISO-8859-1 (Latin-1), Windows-1252 (ANSI, CP 1252 Latin-1), Shift_JIS (SJIS), and Code Page 437 (CP 437). Examples of line ending sequences are UNIX/Linux/Modern macOS - LF (\n); MS-DOS/Windows and Internet text formats - CRLF (\r\n), Classic Macintosh - CR only (\r).
It might contain special sequences of characters such as tabs/spaces/form feeds/control/and so on; and ANSI escape sequence codes as well (such as for cursor/escape key manipulation or for setting special font parameters). Editors will render such codes differently depending whether you see them directly as ASCII code sequences, or whether you interpret some part of such sequences as font formatting codes/escape codes, etc. If used as delimiters for data, TXT file represents record-per-line type of data model. There is no universal data schema such as what are column names; what kind of delimiters for fields; how they should be quoted; what symbols to mark decimal numbers; etc. Also no meta information is stored inside such file - it always will come from filesystem/file permission/http headers/document library properties/and other places.
TXT file format never had universal versioned specification - even though IANA defines text/plain media type with proper handling of character set (in RFC 2046 and 6657 standards). File size of .TXT ranges from a couple of kilobytes up to files of hundreds of gigabytes. Big files will create big trouble for some text editors as they have no ability to handle it - usually they try to read it entirely in its main editor buffer. Also some magic byte sequences can override file naming convention for .txt extension such as wrong file RTF extension starts from 7B 5C 72 74 66 ("{\rtf"), whereas PDF from 25 50 44 46 2D ("%PDF-").
How to convert .TXT files
Switch to PDF format for cases of printing, signing, etc.: Use pandoc in the way: pandoc input.txt -o output.pdf, or go for converting with LibreOffice Writer, MS Word or browser PDF printing functionality. In all cases, the page wrapping, choice of fonts and page breaks is made in PDF software not inherited from original text.
Use DOCX or ODT formats in case team-members need adding of comments, tracking of change marks, creation of footnotes and headers or using of styles: pandoc input.txt -o output.docx; and use LibreOffice: soffice --headless --convert-to odt input.txt. All plain text is formatted automatically but anything that was missing in txt file will disappear after this action.
Use HTML format of your text for web-publication: pandoc input.txt -o output.html. Converter should transform newlines, indentations in paragraphs, hyperlinks in <a href= ... tags etc, and characters as < and > have to be encoded by HTML-notations.
To switch encoding you may want to use iconv, recode, notepad++ (convert function), and even save file with different codepage in Microsoft Visual Studio. Common case could look like: iconv -f WINDOWS-1252 -t UTF-8 input.txt > output.txt. Take precaution and make a back-up in case of uncertainty what character set you're working with. Batch processing works fine with Pandoc, LibreOffice --headless, PowerShell scripting language.
| Convert to | Tool | Command / note |
|---|---|---|
| Pandoc | pandoc input.txt -o output.pdf Creates a paginated document; line wrapping, fonts, and page breaks are chosen by the PDF engine. |
|
| DOCX | Pandoc | pandoc input.txt -o output.docx Plain text becomes simple paragraphs; any original formatting not present in the TXT cannot be reconstructed. |
| HTML | Pandoc | pandoc input.txt -o output.html Useful for publishing text on the web; special characters are escaped and paragraphs may be inferred from blank lines. |
| UTF-8 TXT | iconv | iconv -f WINDOWS-1252 -t UTF-8 input.txt > output.txt Change -f to the real source encoding; incorrect guesses cause mojibake or replacement characters. |
| CSV | Python standard library | python -c "import csv,sys; [csv.writer(sys.stdout).writerow(line.rstrip('\n').split('\t')) for line in open('input.txt', encoding='utf-8')]" > output.csv Appropriate for tab-delimited .txt data; quoted fields and embedded delimiters may require a custom parser. |
| ODT | LibreOffice headless | soffice --headless --convert-to odt input.txt Converts to an editable word-processing document with default import encoding and layout settings. |
| XLSX | LibreOffice headless | soffice --headless --convert-to xlsx input.txt Best for delimited tables; verify delimiter and encoding because automatic import can split columns incorrectly. |
Common problems and fixes
The characters such as é, ’ or the � symbol are usually indicative of the improper usage of the character set when the file has been opened. Open the file in UTF-8, then in Windows-1252, ISO-8859-1, and Shift_JIS; try also the character set the file exporting program was used in. The BOM character (UTF-8 file starting from EF, BB, and BF), the signature (FF, FE or FE, FF) in UTF-16 will look like gibberish in viewers that assume single-byte text.
'The file is too large to be read with this program' or similar messages appear when viewing huge logs, when editors tend to hang on a single huge line going to tens or even hundreds megabytes. The message may also mean not being able to read past some position. Try less, tail or any special viewers, e.g., glogg, or open the file with VS Code which supports very large files viewing.
When each line turns out to be one long paragraph (it may look strange in Excel or Calc), the wrong or absent endings are probably to blame: fix with dos2unix/unix2dos or the line-ending menu in any text editor. For better readability, switch to word wrap in the viewing application.
In MS/ODF spreadsheets (Excel / Calc) the problem that all columns are treated as one field, most likely indicates wrong delimiter and/or locale selection while importing the file. Import the file once again using text import wizard in tabulator/comma/semicolon/pipe delimited/and even fixed widths mode. Set all ZIP codes, account, and similar numbers fields to Text type before opening.
'Permission denied', 'Access is denied': the problem is not with the TXT itself, but with permissions/locked file system/file lock by another application. Adjust the file permissions in the OS GUI, release the file from being locked from its holder application or at least copy elsewhere and use. When a .TXT file begins with '%PDF', 'PK', or some other binary sign, restore the correct extension and use proper application.
Security considerations
Since regular text files do not employ any specific macros, execution capabilities for the objects or automatically launched script coding, a common TXT file normally represents less risk than such file formats as Office and even PDF. The significance of the content resides for the piece of software opening the file, as any vulnerabilities can reside due to badly crafted, very lengthy text line, escape characters or weird encodings. Do not use or execute any commands copied from the external source as a TXT file may include such coding as shell, PowerShell and batch codes which need copying in order to execute or SQL codes to be launched in a proper way through a viewer or interpreter application or even SQL server itself. Logs might use ANSI and VT escape sequences in order to conceal text or manipulate with the title bar of terminal, which is why you should check suspicious log files using safer viewers with removed escape symbols.
History and versions
Simple text format significantly pre-dates the presence of the .TXT file extension. The usage of the .TXT file extension became prevalent with computer programs running on MS-DOS and CP/M where short extensions were used in order to help applications as well as users to recognize file formats. In Unix operating systems, simple texts were declared to be a default type of text file for such files as mailboxes, source, shell scripts, configurations and files containing log messages in order to increase text portability between programs as well as computers and devices. In Internet MIME type text/plain was defined in the form of a document called "Multipurpose Internet Mail Extensions" (RFC 2046) and after that updates by other RFC documents maintained it as registered media types of Internet Assigned Numbers Authority. The usage of Unicode standard and UTF-8 has considerably decreased dependence on national code pages; however there are still many existing older TXT documents using encodings such as CP437, Windows-1252, ISO-8859-1. In Windows OS Notepad program had been traditionally using ANSI encodings but now uses UTF-8 encoding as its default format for simple text files creation.
Related formats
CSV, or comma-separated values is commonly used by Excel, LibreOffice Calc, or database export utilities as a means of exporting rows and columns in accordance with RFC 4180 format guidelines. TXT is more liberal and has a risk of being misinterpreted because of potential existence of commas within it. Tab-separated values, otherwise known as TSV, implies tabs to delineate field separations and similar approach is implemented with regard to TAB delimited files although .tsv is an indicator for such parsers, as .log is a pointer towards append-only time-ordered log-file. In case of markup files (MD and MARKDOWN) heading, bullets and list structures are preserved within the source code, unlike TXT files. RTF supports formatting, coloring, embedded object etc., but DOCX/ODT also contain extra elements within compressed package format. LOG stands for appending of time-ordered records without editing previous content. INI, CFG, CONF, YAML, JSON, or XML have more use in case machines parse files. PDF is a final fixed layout presentation document.
No comments yet. Be the first to share your experience with this file type.