RTF Files: Rich Text Format — The Universal Word Processor Exchange Format
RTF (Rich Text Format) is one of the most successful document interchange formats in computing history. Developed by Microsoft in 1987 as a way to exchange formatted text between different word processing applications, RTF became the de facto standard for cross-application document exchange in the late 1980s and 1990s. Unlike proprietary formats (DOC, WPD, WPS) that required specific software to read, RTF used plain ASCII text with escape codes, making it readable by any text editor and implementable by any developer without a specification license.
Why RTF Mattered (and Still Does)
In 1987, the word processor market was fragmented:
- WordPerfect dominated business
- Microsoft Word was growing
- MultiMate, WordStar, XyWrite, FrameMaker, and dozens of others competed
- Each had incompatible binary formats
RTF provided a vendor-neutral text format that preserved formatting: bold, italic, font sizes, margins, paragraph alignment, tables, and even embedded images — all in plain ASCII text. Most operating systems chose RTF as their built-in rich text format:
- macOS TextEdit: opens and saves RTF natively
- WordPad (Windows): RTF is its native format
- iOS/iPadOS: Notes and Mail support RTF import
- Most word processors: read and write RTF
RTF persists today because it is small, human-readable, works everywhere, and requires no binary parsing library to implement a basic reader.
RTF Syntax
RTF files are plain text (ASCII or Windows-1252 encoding) with:
Control words: Backslash + keyword + optional parameter
\bold1 → bold on
\b → also bold (abbreviated form)
\b0 → bold off
\fs24 → font size 24 half-points (= 12pt)
\par → paragraph break
\pard → reset paragraph formatting to default
Braces: {...} delimit groups. Formatting inside a group is local:
{\b Bold text} Normal text
Control symbols: Special single characters
\* → skip destination (ignore if unknown)
\'xx → hex-encoded character (e.g., \'e9 = é in Latin-1)
\\ → literal backslash
\{ → literal open brace
\} → literal close brace
Minimal RTF Document
{\rtf1\ansi\deff0
{\fonttbl{\f0\froman\fcharset0 Times New Roman;}}
{\colortbl;\red0\green0\blue0;}
\widowctrl\wpaper12240\wpapr9180\margl1800\margr1800\margt1440\margb1440
\deflang1033
\pard\plain\f0\fs24 Hello, World!\par
}
Text Encoding in RTF
RTF was designed for ANSI/Windows-1252 encoding. Non-ASCII characters are encoded as:
\'xx— hex pair for single-byte encoding (\'e9= é)\uN— Unicode code point N, followed by a fallback character
Modern RTF generators use \uN for international text. Older RTF files from the 1990s use \'xx with code page-specific values, which can cause encoding issues when opened on systems with different locale settings.
Applications That Read and Write RTF
Desktop Applications
Microsoft Word: Full read/write RTF support. Word's RTF output includes proprietary extensions (\*\word* control words) that add Word-specific formatting not in the standard.
LibreOffice Writer: Reads and writes RTF. Better standards compliance than Word for pure RTF without proprietary extensions.
macOS TextEdit: RTF is the native format. .rtf files open by default in TextEdit. TextEdit can also open RTFD (RTF Directory) — an RTF package with embedded attachments.
WordPad: Windows built-in RTF editor. Simple but sufficient for basic RTF creation.
AbiWord: Cross-platform open-source word processor with RTF support.
Notepad++ / VS Code: Can open RTF as plain text — you see the markup, not the formatted output. Useful for debugging RTF encoding issues.
Programming Libraries
Python (python-docx, pyrtf-ng, striprtf):
# Strip RTF to plain text (striprtf)
from striprtf.striprtf import rtf_to_text
with open('document.rtf', 'r', encoding='cp1252') as f:
rtf = f.read()
plain_text = rtf_to_text(rtf)
print(plain_text)
Python (pypandoc):
import pypandoc
output = pypandoc.convert_file('document.rtf', 'plain')
Node.js (rtf-parser, textutil): Several npm packages parse RTF to HTML or plain text.
Java (Apache POI): Reads RTF via RTFEditorKit in Swing.
.NET (RichTextBox): The Windows Forms RichTextBox control reads RTF natively with LoadFile(path, RichTextBoxStreamType.RichText).
Converting RTF Files
RTF to DOCX
# Using LibreOffice headless
libreoffice --headless --convert-to docx input.rtf
# Using Pandoc
pandoc input.rtf -o output.docx
RTF to PDF
# LibreOffice
libreoffice --headless --convert-to pdf input.rtf
# Pandoc (via LaTeX — requires LaTeX installation)
pandoc input.rtf -o output.pdf
RTF to HTML
# Pandoc produces clean HTML
pandoc input.rtf -o output.html
# With embedded CSS
pandoc input.rtf -s -o output.html
RTF to Markdown
pandoc input.rtf -o output.md
RTF to Plain Text
# Pandoc
pandoc input.rtf -t plain -o output.txt
# Python (striprtf)
python3 -c "
from striprtf.striprtf import rtf_to_text
print(rtf_to_text(open('input.rtf', 'r', encoding='cp1252').read()))
" > output.txt
# LibreOffice
libreoffice --headless --convert-to txt input.rtf
RTF and Embedded Images
RTF supports embedded images as hex-encoded binary inside \pict groups:
{\pict\pngblip\picw1000\pich800
FFD8FFE000104A46494600... ← hex-encoded PNG data
}
Extracting embedded images from RTF requires a parser. Python's pyrtf or custom hex-dump parsing works for batch extraction.
RTF vs. DOCX: Why RTF Still Has Value
DOCX is newer, more powerful, and the Office standard. RTF has distinct advantages in certain contexts:
| Feature | RTF | DOCX |
|---|---|---|
| Human-readable | ✅ (ASCII text) | ❌ (XML in ZIP) |
| No binary format | ✅ | ❌ |
| Universal support | ✅ Wide | ✅ Wide |
| Complex formatting | Limited | ✅ Full |
| File size | Larger (text) | Smaller (compressed) |
| Programmatic editing | Easy (text processing) | Requires XML libraries |
| Legal/archival use | Common | Growing |
RTF is especially useful when:
- You need to edit documents programmatically using text substitution without XML libraries
- You are working with legacy systems that predate DOCX
- You need a format readable in TextEdit (macOS), WordPad (Windows), or a minimal Linux word processor
- You are building a simple document generator in a language with no Word or DOCX library
For normal day-to-day document exchange, DOCX (or PDF for final distribution) is the better choice.
Related conversions
Document conversions that follow this topic naturally: