ByteScope

RTF file format

Rich Text Format, a cross-platform formatted-text document format.

MIME type
application/rtf
Extensions
.rtf
Category
Documents

Magic-number signature

0x000000007B5C72746631{\rtf1'{\rtf1' header

About the RTF format

RTF is a document format made entirely of printable ASCII: braces open and close groups, backslash-prefixed control words carry the formatting, and everything else is literal text. That makes it the one word-processing format you can read, diff and repair in a text editor, and the one that survives being pasted through a mail client. The price is size and fidelity — an RTF with images is enormous, because every byte of every picture is written out as hexadecimal digits.

Header layout, byte by byte

OffsetLengthFieldMeaning
01Opening group braceThe byte 7B, '{'. The whole document is one group, so this brace is matched by the file's very last byte. Braces nest, and an unbalanced pair is the single most common way an RTF file breaks.
14\rtf control wordThe four bytes 5C 72 74 66. A control word is a backslash followed by lowercase letters and an optional numeric parameter; this one names the format itself and must be the first thing inside the outermost group.
51Version digitThe numeric parameter of \rtf, and in every RTF ever released it is the single ASCII character '1'. The specification has reached version 1.9.1 without ever incrementing this digit, so it identifies the format rather than the revision.
6variableCharacter set control wordThe specification requires the character set immediately after the version. \ansi is what you will see essentially always and occupies five bytes; \mac, \pc and \pca are the legacy alternatives and are shorter, which shifts every offset below.
11variable\ansicpg code pagePresent at exactly this offset when the charset word was the five-byte \ansi. Its parameter is the Windows code page the document's bytes are in — 1252 for Western European, 936 for Simplified Chinese, 932 for Japanese. Characters outside that page are escaped as \'hh or \uNNNN? instead.
variablevariable\deff, \fonttbl and \colortblAfter the code page come the default font index, then the font table group {\fonttbl ...} and usually a colour table {\colortbl ...}. Their offsets depend on everything above them, but they are always groups and always precede the document body, so a hex dump of the first few hundred bytes shows font names in plain ASCII.
-11Closing group braceThe byte 7D, '}', closing the group opened at offset 0. Some writers append a CR LF after it. If the final non-whitespace byte is not a closing brace, the file was truncated — and unlike most formats, you can often repair it by appending the missing braces by hand.

Telling it apart from its neighbours

Easily confused withHow to tell
Word document (docx)Not remotely alike at byte level — '{\rtf1' against 50 4B 03 04 — but they are the two formats people mean by 'a Word file that is not a .doc'. Word opens and writes both, and a .docx renamed to .rtf still opens in Word because Word sniffs the bytes. RTF carries no revision history, no comments thread and no embedded fonts, so 'Save as RTF' is a deliberate way of stripping a document down.
OLE2 / CFBThe genuinely confusing pair, because both are what a '.doc' can turn out to be. A real Word 97 binary document is a Compound File Binary container starting D0 CF 11 E0; a great many files distributed as .doc are actually RTF, because RTF opens everywhere and the extension was more familiar. Read offset 0 rather than the extension: '{\rtf1' is unambiguous.
HTMLBoth are markup made of readable ASCII, and both are what a clipboard hands over when you copy formatted text — Windows offers RTF and HTML on the clipboard simultaneously. They are told apart trivially at offset 0, but the practical distinction is that RTF has no external references at all: no linked stylesheet, no remote image, everything is inline, which is why it is the safer of the two to accept from a stranger.
Text (UTF-8 with BOM)An RTF file is technically plain ASCII text, so a naive detector that only checks for printable bytes will call it text — and a text editor will happily open it and show the markup. The distinguishing test is the six-byte prefix; note also that RTF is not allowed to carry a UTF-8 BOM, since the file must begin with the brace, so EF BB BF at offset 0 means the file has been mangled.

How these files break

  • Unbalanced braces. Because groups nest and control words inherit from the enclosing group, one missing '}' means every formatting attribute set inside that group leaks into the rest of the document. The visible symptom is a file that opens fine and renders the second half in the wrong font or entirely bold, with no error message anywhere.
  • The wrong code page. If \ansicpg says 1252 and the bytes were actually written in 936, every non-ASCII character renders as mojibake. Not one byte of the file is damaged and the document structure is perfectly intact — the single number at offset 11 is what is wrong, and correcting it repairs the whole document.
  • Truncation. An RTF cut short still opens in most word processors, which simply render what they parsed and close the outstanding groups themselves. That leniency is a trap: the document appears complete and is silently missing its last pages. Check that the final non-whitespace byte is '}'.
  • A stray backslash in literal text. Backslash, brace and the escape sequences are the only special characters, so a writer that forgets to escape a literal '\' or '{' turns user text into a control word. The result is text vanishing from the rendered output while remaining plainly visible in a hex dump.
  • Line-ending translation, which for once is harmless. RTF ignores CR and LF outside of control words, so the text-mode transfer that destroys a PNG or a ZIP leaves an RTF perfectly readable. It is one of the few binary-adjacent formats that genuinely survives an ASCII-mode FTP.

Where the format stands today

RTF is a fallback format, and it is still the best one available. Nobody chooses it to author in, but it remains the reliable answer to 'send me something with formatting that will open anywhere', because every word processor written since 1987 reads it and none of them need a plugin. It survives in three places in particular: as the clipboard's formatted-text flavour on Windows and macOS, so every copy-paste of styled text between applications is an RTF round trip; as the export format for legal and government systems that must not depend on a vendor; and as the safe intake format for documents from untrusted sources, since RTF has no macros, no scripting and no external references. Microsoft stopped developing the specification at version 1.9.1 in 2008 and Word's own RTF converter has been deprecated, so it is frozen rather than evolving. For anything new, .docx carries far more fidelity at a fraction of the size — an RTF with a handful of photographs runs to tens of megabytes because images are stored as ASCII hexadecimal, doubling their size before compression, of which there is none.

Open RTF files on this site

Every one of these runs in your browser — the file never leaves your machine.

Related formats

Formats that are easy to confuse with RTF — compare their leading bytes.

FormatFirst bytesExtension
Word document (docx)50 4B 03 04.docx
OLE2 / CFBD0 CF 11 E0 A1 B1.doc
PDF25 50 44 46 2D.pdf

Frequently asked questions

What is a magic number in a file?

The first few bytes of a file, which identify its format regardless of what the name says. A PNG always starts with 89 50 4E 47; a ZIP with 50 4B 03 04. Operating systems, browsers and the file command all read these bytes rather than trusting the extension, which is why renaming a file does not change what it actually is.

How do I check a file's magic number myself?

On macOS or Linux, xxd -l 16 yourfile prints the first 16 bytes; on Windows, Format-Hex -Path yourfile -Count 16 in PowerShell. Or drop the file into the File Type Identifier on this site, which reads the bytes locally and names the format for you — nothing is uploaded.

Why do two formats share the same magic number?

Because one is built on the other. Every docx, xlsx, pptx, apk, jar and epub begins with the ZIP signature, since all of them are ZIP archives underneath; telling them apart means looking at the entries inside. Java class files and macOS universal binaries both start with CA FE BA BE and are distinguished by the field that follows.

Can a file have no magic number at all?

Yes. Text-based formats — XML, HTML, JSON, SVG, CSV — have no fixed byte signature, so they are recognized structurally instead: a leading <?xml declaration, a <svg element, or a { followed by a quoted key. That detection is a good guess rather than a certainty, which is why this reference marks those formats as probe-detected.

Does a matching magic number mean the file is safe?

No. It tells you what the format is, not whether the contents are harmless — a genuine PDF or docx can still carry a malicious payload. Identifying the true type is a useful first check, especially when the extension disagrees with the bytes, but it is not a malware scan.

Have a file that might be in the RTF format? Identify it with the File Type Identifier — it reads the magic number locally, nothing is uploaded. Or browse all formats.