Introduction
A text file holds characters and nothing else: no fonts, no styles, no pictures. Every operating system can open one, and it is the simplest way to keep notes, logs and data that people need to read. It belongs to no program. What it does depend on is how its characters were turned into bytes, its encoding, and how its lines end.
A text file has no header and no length fields: at most a byte order mark, then the characters, split into lines by line-ending characters. Nothing in the file names its encoding except that mark, and most files have none. The encodings come from public standards: ASCII, the ISO 8859 code pages and the Unicode Standard, with its forms UTF-8, UTF-16 and UTF-32.
The same bytes mean different characters in different encodings, so each encoding is a separate format here, with its own reference: UTF-8, UTF-16 and UTF-32 in each byte order, GB18030, EBCDIC, UTF-7, ISO-2022 and HZ, and the legacy code pages. Each code page is strictly a format of its own too, but the bytes do not say which one was used, so they share one page, and the explorer guesses between them.
A file dropped on any page of this site opens in the explorer, which shows its structure (the byte order mark, each line, and the bytes of each character beyond ASCII), the encoding and how it was decided, and a preview of the text.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.TXT | UTF-8 text | Unicode in one to four bytes a character, with ASCII unchanged; the usual text today. | Open |
.TXT | UTF-16LE text | Unicode in two or four bytes a character, low byte first; Windows’ “Unicode”. | Open |
.TXT | UTF-16BE text | Unicode in two or four bytes a character, high byte first. | Open |
.TXT | UTF-32LE text | Every character in four bytes, low byte first. Rare in files. | Open |
.TXT | UTF-32BE text | Every character in four bytes, high byte first. Rare in files. | Open |
.TXT | Legacy code page text | A pre-Unicode code page (Windows-1252, Mac OS Roman, DOS 437, Shift_JIS …), guessed. | Open |
.TXT | UTF-7 text | Unicode written as pure ASCII, with runs of Base64 holding UTF-16 units. | Open |
.TXT | ISO-2022 and HZ text | 7-bit Japanese, Korean and Chinese text, with escape sequences that switch character sets. | Open |
.TXT | GB18030 text | China’s national encoding: one, two or four bytes a character, covering all of Unicode. | Open |
.TXT | EBCDIC text | IBM mainframe text, not based on ASCII: a space at 40, letters at 81 and C1. | Open |
.TXT | SCSU text | Unicode text compressed with windows and tags (UTS #6); starts 0E FE FF. | Open |
.TXT | BOCU-1 text | Unicode text as differences between code points (UTN #6); starts FB EE 28. | Open |
.TXT | UTF-1 text | The early ISO 10646 transformation that UTF-8 replaced; starts F7 64 4C. | Open |
.TXT | UTF-EBCDIC text | UTF-8 for EBCDIC systems (UTR #16); starts DD 73 66 73. | Open |
UTF-8 text
The usual text today. Each Unicode character takes one to four bytes, and the 128
ASCII characters keep their one-byte values, so a pure ASCII file is a UTF-8 file. A
byte order mark, EF BB BF, is optional and uncommon.
It starts with EF BB BF, or every byte sequence in it is valid UTF-8,
which text in any other encoding almost never is by chance.
UTF-16LE text
Unicode in 16-bit units, low byte first: two bytes for most characters, four for those above U+FFFF. It is what Windows means by “Unicode”, and Windows writes it with a byte order mark.
It starts with FF FE, or, in text that is mostly ASCII or Latin, the
second byte of nearly every pair is zero.
UTF-16BE text
The same 16-bit units, high byte first. It is the default when text is labelled only “UTF-16”, but rare as files.
It starts with FE FF, or the first byte of nearly every pair is
zero.
UTF-32LE text
Every character as one 32-bit number, its code point, low byte first. Simple, and four times the size of ASCII, so it is used in memory more than in files.
It starts with FF FE 00 00 and what follows is UTF-32, or every
4-byte unit, read low byte first, is a code point no higher than
10FFFF.
UTF-32BE text
The same 32-bit numbers, high byte first. Rarer still.
It starts with 00 00 FE FF, or every 4-byte unit, read high byte
first, is a code point.
Legacy code page text
Text in one of the code pages from before Unicode: Windows-1252, ISO 8859-1, Mac OS Roman, DOS code page 437, the Cyrillic code pages, or the double-byte code pages of China, Japan and Korea. The file does not say which, so the explorer guesses, and says that it is a guess.
It is what is left: text that is none of the other formats. A single-byte code page accepts every byte, so there is no positive test.
UTF-7 text
Unicode written as pure ASCII, for 7-bit mail: letters and digits as themselves,
anything else in a run of modified Base64 holding UTF-16 units, between a
+ and usually a -.
Every byte is ASCII, every + starts a well-formed run, and at least
one run holds a character beyond ASCII.
ISO-2022 and HZ text
Japanese, Korean and Chinese as 7-bit text: ISO-2022-JP, ISO-2022-KR, ISO-2022-CN, and HZ, which escape sequences switch between ASCII and double-byte character sets.
Every byte is below 80, and the file holds one of their shift
sequences, or HZ’s ~{.
GB18030 text
China’s national encoding, one, two or four bytes a character, covering all of Unicode, from GB 18030-2000 onwards.
It starts with 84 31 95 33, or the bytes are valid GB18030 and at
least one character takes four bytes. Without either it cannot be told from GBK.
EBCDIC text
IBM mainframe text, not based on ASCII: the space is 40, the digits
F0 to F9, and the letters in three runs.
The space byte, the EBCDIC letters and digits are common and the ASCII letter ranges rare. The code page is guessed, and the file is shown in each one the explorer knows. Files with double-byte characters between SO and SI are read too.
SCSU text
Unicode compressed with windows and tags (UTS #6): one byte a character in a small alphabet, with tag bytes that move a 128-character window.
It starts with 0E FE FF, U+FEFF quoted.
BOCU-1 text
Unicode as the difference between each character and the one before (UTN #6), in one to four bytes, with the C0 controls as themselves.
It starts with FB EE 28, U+FEFF.
UTF-1 text
The early ISO 10646 transformation of 1993 that UTF-8 replaced: one, two, three or five bytes a character, with arithmetic modulo 190 on the trail bytes.
It starts with F7 64 4C, U+FEFF.
UTF-EBCDIC text
UTF-8 for EBCDIC systems (UTR #16): UTF-8 with the C1 controls as single bytes, its bytes then mapped through a fixed table.
It starts with DD 73 66 73, U+FEFF.
Telling them apart
The explorer takes a file as plain text when its name ends in .txt,
.text, .diz, .nfo or .log, or when
its name ends in .com, .doc, .dot or
.pot and its first bytes look like text. A file with no extension is taken when its first 64 KB look like text: a byte order mark,
the zero bytes or whole-unit line breaks of UTF-16 and UTF-32, GB18030’s or EBCDIC’s
characteristic bytes, or no NUL bytes, few control characters, and either valid
UTF-8 or few bytes above 7F. Files named Makefile go to
their own format, and other extensions
(.md, .csv, .json …) to theirs. An empty file
is not taken: there is nothing to show.
Then the formats are tried in this order, and the first that accepts the file wins:
- UTF-7 and ISO-2022 and HZ, because every byte of them is ASCII and only a positive test can tell them from plain ASCII.
- UTF-8, then, because it is by far the commonest and its test is exact. Without a byte order mark, the first invalid sequence turns the file down.
- UTF-32LE and
UTF-32BE, before UTF-16, because
FF FE 00 00is both UTF-32LE’s byte order mark and UTF-16LE’s followed by U+0000. UTF-32LE turns the file down when what follows is not UTF-32. - UTF-16LE and UTF-16BE, by byte order mark, zero bytes or line breaks and spaces as whole units.
- GB18030, by its byte order mark or a valid four-byte sequence.
- EBCDIC, by its byte statistics.
- The legacy code pages, last, because they accept nearly anything that is not binary.
A .txt file that no format accepts, usually binary data under a text
name, is still shown, as the format that read furthest, with its problems reported. A
file with no extension that turns out not to be text is left to the hex view.
Among the files examined for this site nearly every .txt file was UTF-8,
most of them pure ASCII. A few hundred were in legacy code pages, about two dozen in
UTF-16LE and two in UTF-32LE; none was UTF-16BE or UTF-32BE.
Versions
Plain text has no versions of its own; its encodings do. Each row gives the format that text in that encoding is read as here.
| Year | Release | Format |
|---|---|---|
| 1963 | ASCII (ASA X3.4-1963), a 7-bit code; revised 1967 and 1986 | UTF-8 (ASCII is part of it), Legacy |
| 1964 | EBCDIC, with the IBM System/360 | EBCDIC |
| 1981 | The IBM PC and its code page 437 | Legacy |
| 1984 | The Apple Macintosh and Mac OS Roman | Legacy |
| 1987 | ISO 8859-1 (Latin-1); further parts of ISO 8859 follow, up to 8859-16 | Legacy |
| Late 1980s and 1990s | The Windows “ANSI” code pages: Windows-1252 for Western Europe, 1250, 1251 and others (exact years vary and are not given here; the euro sign was added to 1252 later) | Legacy |
| 1991 | Unicode 1.0: every character in 16 bits, the form now called UCS-2 | UTF-16LE, UTF-16BE |
| 1992 | UTF-8 designed by Ken Thompson and Rob Pike for Plan 9; presented at USENIX in January 1993 | UTF-8 |
| 1993 | KOI8-R in RFC 1489 | Legacy |
| 1996 | Unicode 2.0: surrogate pairs, so UTF-16 reaches beyond U+FFFF; UTF-8 in RFC 2044 | UTF-16LE, UTF-16BE, UTF-8 |
| 1993 | ISO-2022-JP in RFC 1468 (with RFC 1557 for Korean in 1993 and RFC 1922 for Chinese in 1996), and HZ in RFC 1843 (1995) | ISO-2022 and HZ |
| 1997 | UTF-7 in RFC 2152, replacing RFC 1642 (1994) | UTF-7 |
| 1998 | RFC 2279: UTF-8, with forms of up to six bytes | UTF-8 |
| 2000 | RFC 2781: UTF-16 and its byte order mark | UTF-16LE, UTF-16BE |
| 2000 | GB 18030-2000 (17 March) | GB18030 |
| By 2002 | UTF-32, in Unicode Standard Annex #19; part of the core standard from Unicode 4.0 (2003) | UTF-32LE, UTF-32BE |
| 2003 | RFC 3629: UTF-8 limited to U+10FFFF and four bytes, with no overlong forms or surrogates | UTF-8 |
| 2005 | GB 18030-2005 (8 November); U+1E3F and U+E7C7 swap places | GB18030 |
| 2023 | GB 18030-2022 in force (1 August); 18 more characters remapped | GB18030 |
| 2026 | Unicode 18.0, dated 16 September 2026 (its page at unicode.org was still marked preliminary when this was written); the WHATWG Encoding Standard, last updated 19 October 2026 | all |
Each Unicode version adds characters but keeps UTF-8, UTF-16 and UTF-32 as they are, so a new version needs no new format.
Other encodings
ASCII is the first half of UTF-8 and of most code pages; its 128 codes, with the name and function of each control code, are on the legacy code page reference. UCS-2 is UTF-16 without surrogate pairs, and UCS-4 is the wider 31-bit form of UTF-32; the pages for those formats cover the differences. A file in a code page or Unicode form the explorer does not read is shown in whichever format fits, most often as a legacy code page, with the wrong characters. These are not read:
- The JIS X 0213 extensions of Shift_JIS and EUC-JP (Shift_JIS-2004, EUC-JIS-2004). JIS X 0213 is read inside ISO-2022-JP-3 and -2004.
- EBCDIC code pages other than the 31 the EBCDIC page lists.
- Other regional encodings that have no page here.
These are read: ISO-2022-JP, -JP-2, -JP-3 and -JP-2004, ISO-2022-KR, ISO-2022-CN and -CN-EXT (CNS 11643 planes 1 to 7 and ISO-IR-165), HZ, the EBCDIC pages 037, 500, 1047, 273, 277, 278, 280, 284, 285, 297, 871, 420, 424, 870, 875, 1025, 1140 to 1149 and the mixed pages 930, 933, 935, 937 and 939, VISCII, TCVN, and SCSU, BOCU-1, UTF-1 and UTF-EBCDIC.
Related formats
Many formats are plain text with rules of their own, and have their own pages:
- Markdown – plain text with light marks for headings, emphasis, lists and links
- reStructuredText – plain text markup used for Python documentation
- AsciiDoc – plain text markup for technical documents and books
- Org mode document – Emacs’s outlines, notes and plans in plain text
- LaTeX and TeX source – plain text typeset into documents
- Comma-separated values – a table as lines of comma-separated fields
- Tab-separated values – a table as lines of tab-separated fields
- JavaScript Object Notation – structured data as text, always in Unicode
- Extensible Markup Language – tagged text that names its own encoding
- YAML – structured data written as indented text
- Plain text log – a program’s messages, one per line
- SubRip subtitles – numbered, timed lines of text
- Makefile – build rules in a text file with no extension
Not described
Known, not yet covered
- Reference and viewer: Shift_JIS-2004 and EUC-JIS-2004, the JIS X 0213 forms of Shift_JIS and EUC-JP (read as Shift_JIS or EUC-JP, with the wrong characters for the JIS X 0213 cells). JIS X 0213 is read inside ISO-2022-JP-3 and -2004 (ISO-2022 page).
- Reference and viewer: EBCDIC code pages other than the 31 on the EBCDIC page; the files show as the nearest page, or as legacy text.
- Reference and viewer: JIS C 6226-1978 (
ESC $ @): the 39 special characters that the 1983 revision added to row 2 are not identified, so row 2 is read as 1983. The explorer flags only row 8 and 84-01 to 84-04 (ISO-2022 page). - Reference and viewer: ISO-IR-165 cells where ICU’s table and libiconv’s disagree (rows 2A and 2B, and eight cells of GB 2312’s rows: 21 2B, 21 67, 21 69, 21 6A, 23 67, 28 3C, 28 3F, 28 40), and 25 CNS 11643 plane 3, 4 and 7 cells where ICU has the 2014 edition and libiconv an older one. The explorer follows ICU; the ISO-IR 165 registration is a scanned chart that could not be read to settle them.
- Reference and viewer: GB 18030’s single byte
80(shown as € as browsers do, though GB 18030 has none) and the four-byte codes that GB 18030-2022 changed (GB18030 page). - Reference: the names of the EBCDIC control codes come from Wikipedia’s table; IBM’s own list was not found online.
- Viewer: the caption under a truncated Text tab says only “The start of the file is shown.”, not how much (16 MB). That caption is in the shared viewer component, outside the plain text plugin.
Links
Software
- Notepad – the text editor built into Windows (Windows)
- TextEdit – the text editor built into macOS (macOS)
- Notepad++ – free text and code editor with encoding and line-ending tools (Windows)
- Visual Studio Code – free code editor (Windows, macOS, Linux)
- Sublime Text – fast text and code editor (Windows, macOS, Linux)
- BBEdit – long-standing Mac text editor (macOS)
- Vim – keyboard-driven text editor (Windows, macOS, Linux)
- GNU Emacs – extensible text editor (Windows, macOS, Linux)
- dos2unix – converts line endings, and some encodings (Windows, macOS, Linux)
- file – the Unix
filecommand, which names a text file’s encoding and line endings (macOS, Linux)
Developers
- ICU – conversion between encodings and charset detection (C, C++, Java)
- GNU libiconv – the iconv conversion library and command (C)
- chardet – guesses a file’s encoding (Python)
- uchardet – encoding detector from Mozilla’s code (C)
- encoding_rs – the WHATWG encodings, as used by Firefox (Rust)
- ftfy – repairs mojibake (Python)
- TextDecoder – browsers’ built-in decoder (JavaScript)
Reference
- The Unicode Standard – encoding forms (chapter 3) and newline guidelines (chapter 5)
- Unicode FAQ: UTF-8, UTF-16, UTF-32 and BOM – the Unicode Consortium’s answers on encodings and byte order marks
- RFC 3629 – UTF-8
- RFC 2781 – UTF-16 and its byte order mark
- RFC 2152 – UTF-7
- UAX #14 – line breaking, including mandatory breaks
- UTR #26 – CESU-8
- WHATWG Encoding Standard – the encodings browsers support, with their tables
- Unicode’s code page mapping files – CP437, CP1252, Mac OS Roman and others
- RFC 1489 – KOI8-R