RTF (Rich Text Format) — Complete Document Format Guide
What Is RTF?
RTF (Rich Text Format) is a document file format developed by Microsoft in 1987, initially for cross-platform document exchange between Microsoft Word and other word processors. Unlike DOCX (a ZIP archive of XML files) or PDF (a binary layout format), RTF is a plain-text format — the entire document, including formatting instructions, is stored as readable ASCII text that can be opened in any text editor.
RTF encodes formatted text using a system of control words (keywords preceded by a backslash) embedded within the text content. This makes RTF inherently human-readable (though not elegantly readable) and parseable by simple text-processing tools.
RTF Syntax and Structure
Control Words and Groups
RTF documents are organised into groups delimited by braces {}:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033
{\fonttbl{\f0\froman\fcharset0 Times New Roman;}}
{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}
{\*\generator Microsoft Word 2019;}
\viewkind4\uc1
\pard\sa200\sl276\slmult1
\f0\fs24 This is \b bold text\b0 and this is \i italic\i0 .\par
{\cf2 Red text example.}\par
}
Key Control Words
Document settings:
\rtf1— identifies the file as RTF version 1 (the current and only widely-used version)\ansi— character set (ansi, mac, pc, pca)\deff0— default font (index into the font table)\deflang1033— default language (1033 = English US)
Font table (\fonttbl): Lists all fonts used in the document with their family and charset:
{\fonttbl
{\f0\froman\fcharset0 Times New Roman;}
{\f1\fswiss\fcharset0 Arial;}
{\f2\fmodern\fcharset0 Courier New;}
}
Colour table (\colortbl): Defines a palette of colours referenced by index:
{\colortbl;\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;}
Character formatting:
\b/\b0— bold on/off\i/\i0— italic on/off\ul/\ulnone— underline on/off\strike— strikethrough\fs24— font size in half-points (24 = 12pt)\cf2— colour foreground index 2\f1— switch to font index 1
Paragraph formatting:
\pard— reset paragraph to default settings\par— paragraph break\line— soft line break (within paragraph)\ql,\qr,\qc,\qj— left, right, centre, justify alignment\li720— left indent (720 twips = 0.5 inches; 1 inch = 1440 twips)\sb240— space before paragraph (240 twips)\sl276\slmult1— line spacing (276 twips, multiple mode)
Tables:
\trowd\trqc\cellx4320\cellx8640
\intbl First cell \cell Second cell \cell\row
Supported Features
RTF 1.9 (the final specification, 2008) supports:
- Typography: font families, sizes, colours, bold, italic, underline, strikethrough, superscript/subscript, hidden text
- Paragraph formatting: alignment, indentation, line spacing, spacing before/after, borders, shading
- Tables: rows, cells, borders, cell merging (via rowspan/colspan equivalents)
- Lists: bulleted and numbered lists (via list table in RTF 1.3+)
- Embedded objects: OLE objects, embedded images (WMF, EMF, JPEG, PNG, BMP as hex-encoded data)
- Hyperlinks: clickable links via
HYPERLINKfield - Bookmarks: named anchors for internal navigation
- Comments/annotations (via the
\cscharacter style and comment groups) - Track changes / revision marks (limited; DOCX handles this more completely)
- Headers and footers
- Page settings: page size, margins, orientation
What RTF Cannot Do Well
- Complex layouts: multi-column text, text frames, advanced positioning are awkward in RTF
- Styles: style sheets exist (paragraph and character styles via
\stylesheet) but poorly preserved across conversions - Track changes: revision tracking is limited compared to DOCX
- Metadata: document properties (author, title, keywords) stored in
\infogroup but with limited field support - Accessibility: no semantic structure (headings are just large bold text, not marked as heading objects)
- Unicode: original RTF uses escape sequences
\'XXfor non-ASCII characters; Unicode RTF (\uc1荤?) is clumsy
File Characteristics
- Extension:
.rtf - MIME type:
application/rtfortext/rtf - Typical size: 2–10× larger than DOCX for the same content (plain text overhead of control words; embedded images stored as hex, doubling their size)
- Encoding: ASCII with Unicode escape sequences for non-ASCII characters
- Maximum: no inherent limit; very large RTF files (books, technical manuals) are common
Platform and Application Support
Native Support
- Microsoft Word (all versions) — RTF is the universal Word interchange format; used when "Save as" to RTF
- WordPad (Windows) — uses RTF as its native format (
.rtf) - TextEdit (macOS) — opens and saves RTF natively
- LibreOffice / OpenOffice Writer — excellent RTF import/export
- Google Docs — imports RTF; does not export RTF directly
- Apple Pages — imports RTF; exports RTF (limited fidelity)
- Email clients (Outlook) — Outlook uses RTF internally for complex formatted emails sent to Exchange recipients
Programmatic Support
RTF's plain-text nature makes it easy to generate programmatically:
- Reporting systems — many enterprise reporting tools output RTF for editable reports
- Legal document systems — some legal practice management software generates RTF for court filings
- Mail merge output — generated RTF files are commonly used for personalised document batches
Security Considerations
RTF has been the vector for numerous security vulnerabilities due to its complex parser surface area:
- CVE-2010-3333 — Microsoft Word RTF stack buffer overflow (exploited by targeted attacks)
- CVE-2012-0158 — Office RTF use-after-free (highly exploited; patched in MS12-027)
- RTF Object Injection — malicious OLE objects or shell commands embedded in RTF
- Equation Editor exploits —
\objdatawith malicious Equation Editor content
Security recommendation: open RTF files from untrusted sources in Protected View (Word) or in Google Docs (sandboxed) rather than natively in a local application.
Converting RTF Files
RTF → DOCX: Convert to modern Office format; preserves most formatting; recommended for ongoing editing RTF → PDF: Convert for read-only distribution; preserves layout; not editable RTF → ODT: Convert to open format for LibreOffice/OpenOffice workflows RTF → HTML: Convert for web publishing; strip formatting or map styles to CSS RTF → TXT: Extract plain text; all formatting lost; useful for content extraction DOCX → RTF: Convert for sharing with legacy systems, Outlook Rich Text emails, or applications with RTF-only support
Related conversions
Document conversions that follow this topic naturally: