Skip to main content
Technology & EngineeringFile Formats141 lines

RTF (Rich Text Format)

A Microsoft-developed text-based document interchange format that encodes formatted text with control words, providing cross-platform rich text exchange without binary complexity.

Quick Summary28 lines
You are a file format specialist with deep expertise in RTF (Rich Text Format), including control word syntax, group nesting, font and color table construction, programmatic RTF generation, and cross-platform document interchange.

## Key Points

- **File extension:** `.rtf`
- **MIME type:** `application/rtf` or `text/rtf`
- **Latest version:** RTF 1.9.1 (2008, last Microsoft update)
- **Magic bytes:** `{\rtf1` at file start
- **Character encoding:** ASCII with Unicode escapes (`\u` followed by decimal code point)
- **Max file size:** No format limit
- **Control words:** `\b` (bold), `\i` (italic), `\fs` (font size in half-points), `\par` (paragraph break)
- **Groups:** `{ }` define scope for formatting changes
- **Font table:** `{\fonttbl ...}` declares available fonts
- **Color table:** `{\colortbl ...}` defines color palette
- **Pictures:** Embedded as hex-encoded data with `\pict` groups
- **Windows:** WordPad (built-in), Microsoft Word, LibreOffice

## Quick Example

```rtf
{\rtf1\ansi\deff0
{\fonttbl{\f0 Times New Roman;}}
{\colortbl;\red255\green0\blue0;}
\pard\f0\fs24 Hello, {\b bold} and {\cf1 red text}.\par
}
```
skilldb get file-formats-skills/RTF (Rich Text Format)Full skill: 141 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in RTF (Rich Text Format), including control word syntax, group nesting, font and color table construction, programmatic RTF generation, and cross-platform document interchange.

RTF — Rich Text Format

Overview

Rich Text Format is a document file format created by Microsoft in 1987 for cross-platform document interchange. Unlike binary formats like DOC, RTF uses a text-based markup system with control words (backslash-prefixed commands) to encode formatting. RTF was designed as a lingua franca for word processors — a format any application could read and write without needing to understand proprietary binary structures. While its importance has diminished with the rise of DOCX and ODF, RTF remains useful as a lightweight interchange format.

Core Philosophy

RTF (Rich Text Format) was created by Microsoft in 1987 as a cross-platform document interchange format that could preserve basic formatting (fonts, colors, bold, italic, tables) while remaining human-readable and parseable without proprietary software. RTF's philosophy was pragmatic: provide enough formatting for business documents without the complexity of full word processor file formats.

RTF served as a bridge format for decades, enabling document exchange between Word, WordPerfect, and other word processors that used incompatible native formats. Today, that bridge role has been largely supplanted by DOCX and PDF. RTF remains relevant in specific contexts: clipboard interchange (copy-paste with formatting), email composition, legacy system integration, and environments where a simple, well-understood rich text format is needed without the complexity of OOXML.

For new projects, there is rarely a reason to produce RTF. Use DOCX for editable documents, PDF for fixed-layout documents, and Markdown or HTML for web-oriented content. RTF is most useful as a lowest-common-denominator format when you need rich text that every text editor can open and you cannot assume DOCX or HTML support.

Technical Specifications

  • File extension: .rtf
  • MIME type: application/rtf or text/rtf
  • Latest version: RTF 1.9.1 (2008, last Microsoft update)
  • Magic bytes: {\rtf1 at file start
  • Character encoding: ASCII with Unicode escapes (\u followed by decimal code point)
  • Max file size: No format limit

Structure

RTF is a plain-text format using nested groups (curly braces) and control words:

{\rtf1\ansi\deff0
{\fonttbl{\f0 Times New Roman;}}
{\colortbl;\red255\green0\blue0;}
\pard\f0\fs24 Hello, {\b bold} and {\cf1 red text}.\par
}

Key structural elements:

  • Control words: \b (bold), \i (italic), \fs (font size in half-points), \par (paragraph break)
  • Groups: { } define scope for formatting changes
  • Font table: {\fonttbl ...} declares available fonts
  • Color table: {\colortbl ...} defines color palette
  • Pictures: Embedded as hex-encoded data with \pict groups

How to Work With It

Opening

  • Windows: WordPad (built-in), Microsoft Word, LibreOffice
  • macOS: TextEdit (native support), Word, LibreOffice
  • Linux: LibreOffice Writer, AbiWord
  • Any platform: Most word processors support RTF

Creating

  • WordPad (Windows) saves RTF natively
  • TextEdit (macOS) can save as RTF
  • Microsoft Word: Save As > Rich Text Format
  • LibreOffice Writer: Save As > Rich Text Format (.rtf)
  • Programmatically: Since it is plain text, RTF can be generated with string concatenation in any language

Parsing

  • RTF can be read as text and parsed with custom parsers
  • Python: striprtf (text extraction), pyrtf-ng (creation)
  • Java: Swing's RTFEditorKit for basic parsing
  • .NET: RichTextBox control handles RTF natively
  • Command line: unrtf converts RTF to HTML/text on Linux

Converting

  • To PDF: LibreOffice headless, Word, or Pandoc
  • To DOCX: LibreOffice, Word, Pandoc
  • To HTML: unrtf --html, Pandoc
  • To plain text: unrtf --text, Pandoc, or striprtf (Python)
  • From other formats: Pandoc supports RTF as output target

Common Use Cases

  • Cross-application clipboard format (rich text copy/paste uses RTF internally on many platforms)
  • Simple formatted documents that need wide compatibility
  • Email composition in some older clients
  • Legal document exchange in some jurisdictions
  • Legacy system integration where DOCX is not supported
  • Readme files and documentation in systems requiring basic formatting

Pros & Cons

Pros

  • Human-readable text format (can inspect/edit with a text editor)
  • Universally supported by word processors across all platforms
  • No macros or scripting — inherently safer than DOC/DOCX
  • Simple enough to generate programmatically without libraries
  • Stable format — no version churn since 2008
  • Good for clipboard interchange between applications

Cons

  • Limited formatting compared to DOCX or ODF (no styles hierarchy, limited table support)
  • Verbose — files can be much larger than equivalent DOCX
  • No standardization body (Microsoft specification only)
  • Microsoft ceased active development in 2008
  • No native support for modern features (comments, tracked changes, content controls)
  • Image embedding is inefficient (hex-encoded binary data)
  • Security vulnerabilities have been found in RTF parsers historically

Compatibility

PlatformNative Support
WindowsWordPad (built-in), Word, LibreOffice
macOSTextEdit (built-in), Word, LibreOffice
LinuxLibreOffice, AbiWord, unrtf
WebNo native browser support; requires conversion
MobileMost mobile office apps can open RTF

RTF is one of the most widely supported rich text formats, though rendering of complex formatting may vary between applications.

Related Formats

  • DOCX (.docx): Modern replacement for rich document exchange
  • DOC (.doc): Binary format RTF was designed to complement
  • HTML (.html): Another text-based format for formatted content
  • TXT (.txt): Plain text without formatting
  • Enriched Text (RFC 1896): IETF alternative (rarely used)

Practical Usage

  • Use RTF as a lightweight interchange format when you need basic formatting (bold, italic, fonts, colors) without the complexity of DOCX or ODF.
  • Generate RTF programmatically with simple string concatenation -- the text-based control word syntax is straightforward enough to build without a library for simple documents.
  • Use unrtf --text on Linux for quick text extraction from RTF files in automated pipelines.
  • Prefer RTF over DOC when exchanging documents with unknown recipients -- RTF has no macro capability, making it inherently safer than DOC/DOCX.
  • Use Pandoc for converting RTF to/from Markdown, HTML, or DOCX in batch workflows.
  • Remember that RTF 1.9.1 (2008) is the final version -- do not expect new features or improvements to the format.

Anti-Patterns

  • Using RTF for complex document layouts -- RTF has limited support for tables, headers/footers, and page layout compared to DOCX; use DOCX or ODF for anything beyond basic text formatting.
  • Embedding large images in RTF -- Images are hex-encoded in RTF, doubling the raw image size and producing very large files; use DOCX or PDF for image-heavy documents.
  • Choosing RTF for new projects when DOCX or Markdown would serve better -- RTF development ceased in 2008 and the format is effectively legacy; use DOCX for rich documents or Markdown for lightweight formatted text.
  • Trusting RTF files from untrusted sources as inherently safe -- While RTF lacks macros, historical vulnerabilities in RTF parsers (particularly in Microsoft Word and Outlook) have been exploited in targeted attacks; always keep software updated.
  • Assuming all RTF features render consistently across applications -- Different applications support different subsets of RTF control words; test rendering in the target application before distributing.

Install this skill directly: skilldb add file-formats-skills

Get CLI access →