Introduction
RTF is a document format that Microsoft introduced in 1987 for exchanging formatted text between word processors. It is plain text with formatting written as control words, so almost any word processor can read it and the source stays readable. The last version of the specification, 1.9.1, was published in 2008.
Structure
An RTF document is one group in braces that starts with \rtf1. Inside,
control words begin with a
backslash and may take a number, such as \b for bold, \b0 to
end it, \fs24 for a 12 point font (sizes are in half points) and
\par to end a paragraph. Nested groups in braces keep formatting changes
local. Groups that start with a destination word hold text that goes elsewhere, such as
a footnote, or is not shown, such as the font table; \* before one tells a
reader to skip it if it does not know it. Characters outside ASCII are written as
escapes such as \'e9 or \u233?, and pictures as hexadecimal
data.
The header comes first: the character set, then tables of fonts, files, colours, styles, lists and revision authors, which the text refers to by number. Then comes the document: summary information and document properties, and one or more sections of paragraphs. Tables are rows of paragraphs, and the text carries character formatting, pictures and objects, drawings, and fields, notes and bookmarks.
{\rtf1Version and character set\ansi,\ansicpg,\deffheader{\fonttblFont table numbered fonts with family and character setheader{\colortblColour table, then style sheet, list and revision tablesoptional{\infoInformation group title, author, dates, countsoptional\paperw…Document properties page size, margins, notes, optionsoptional\sectd…Sections of paragraphs, tables and text, ended by\sectone or more}End the closing brace of the outer group1 byte
This site’s reference pages follow the RTF Specification 1.6 (Word 2000, 1999), and each page ends with an “Added after RTF 1.6” section for the control words that the last specification, 1.9.1 (19 March 2008, Word 2007), adds: themes, latent styles, table styles, revision save IDs, compatibility options, custom XML and more. Two areas new in 1.9.1 have their own pages: mail merge and Office Math. Every control word in the 1.9.1 index appears on some page.
{\rtf1\ansi\deff0
{\fonttbl{\f0 Times New Roman;}}
\f0\fs24 Plain text, {\b bold text} and plain again.\par
}
Not described
These pages follow Microsoft’s RTF specification 1.6 and the 1.9.1 specification for the words added after it. The explorer reads an RTF file into its groups, control words and text.
Known, not yet covered
- Viewer: the structure, text, fonts, colours, styles, information, pictures, objects, fields and every control word are shown; the meanings of the control words come from the 1.9.1 index and are given for about 900 of its 1,800 words (the Document formatting, Drawing, Math, Mail merge, Numbering and Table style words are listed with their type and section only). The list table, list overrides, revision marks, shapes, headers, footers, footnotes, fields other than their text, and tables are shown as groups and control words, not interpreted: no layout is drawn, and the text of headers, footers and footnotes is left out of the document text.
- Viewer: a picture opens as a file only when the explorer reads its type (PNG, JPEG, bitmap); metafiles, QuickDraw and device-dependent bitmaps open as bytes. An object opens as its \objdata bytes and its OLE 1 native data; the OLE 2 storage inside is not opened.
Unknown
- Reference:
\cgrid,\g,\gcw,\gridtbland\affixedare only named in the specification, not explained. - Reference: the values of
\posvare printed as “1 Center, 2 Column”, which probably means 1 top and 2 centre. - Reference: the value types of shape angles (16.16) and colours (0x00BBGGRR) are how Word
writes them, not stated in 1.6; the specification also contradicts itself in spellings such as
\mmblanklinesagainst\mmblanklinks, which the pages note.
Links
Software
- Microsoft Word – Microsoft’s word processor, which opens and saves RTF (Windows, macOS, web, mobile)
- LibreOffice Writer – free office suite’s word processor, which opens and saves RTF (Windows, macOS, Linux)
- TextEdit – the Mac’s built-in text editor, which uses RTF for formatted text (macOS)
- Google Docs – online word processor that imports and exports RTF (web browsers)
- Pandoc – command-line converter that reads and writes RTF (Windows, macOS, Linux)
Reference
- Rich Text Format (RTF) Specification, version 1.9.1 – Microsoft’s last specification of the format, March 2008, as the PDF copy referenced by Microsoft’s Open Specifications
- Rich Text Format (RTF) Specification, version 1.6 – Microsoft’s 1999 specification as web pages, kept by the LaTeX2RTF project
- Rich Text Format (RTF) Specification, version 1.5 – the 1997 specification on one page