File types · Explainer

The RTF file (.rtf)

An RTF file is a formatted text document written as plain text, with control words such as \b for bold, that almost every word processor can open. This guide explains what's inside one, where it is still used, its history as a carrier for attacks, and has free sample RTF files to download for testing.

At a glance

Full name
Rich Text Format
Extensions
.rtf
MIME type
application/rtf; text/rtf is also registered
Kind
Plain text, usually 7-bit ASCII, with formatting as control words
Owner
Microsoft, which publishes the specification
First released
1987, by Microsoft; specification 1.0 published in 1992
Latest version
1.9.1 (March 2008, matching Word 2007); no longer extended
Units
Twips (1/1440 inch) for layout, half-points for font sizes
Opens with
Microsoft Word, LibreOffice Writer, TextEdit on macOS, Google Docs
Magic number
7B 5C 72 74 66 31 ({\rtf1)

The basics

What is an RTF file?

RTF is a document format Microsoft created in the 1980s so that formatted text could move between word processors and operating systems. An RTF file holds the text plus its fonts, sizes, colours, paragraph styles, tables, lists, images and page layout, all written as readable control words in a plain-text file.

It's no longer the main format of any big word processor, but it hasn't gone away. TextEdit on the Mac saves formatted documents as RTF by default. Copying formatted text between apps often travels as RTF on the clipboard. Many programs export reports, letters and templates as RTF because it's simple to generate and opens in almost every word processor.

  • It's text, not a package. Open an RTF file in a plain-text editor and you see the control words and the text between them. A DOCX is a ZIP of XML files instead.
  • It's not a fixed layout. Like DOCX, the reading app lays out the lines and pages, so the same file can paginate differently in Word and LibreOffice.
  • It's frozen. Microsoft stopped extending RTF after version 1.9.1 (2008). Features added to Word since then have no RTF equivalent and are lost when you save as RTF.

Anatomy

What's inside an RTF file

An RTF file is built from three things: control words that start with a backslash, groups in curly braces that limit what a control word applies to, and the text itself. Here is a small but complete document, part by part.

note.rtf
{\rtf1\ansi\ansicpg1252\deff0
{\fonttbl{\f0\froman Times New Roman;}{\f1\fswiss Arial;}}
{\colortbl;\red0\green0\blue0;\red200\green30\blue40;}
{\info{\title A short note}{\author Ada Example}}
{\*\generator Example Writer 1.0;}
\paperw11906\paperh16838\margl1440\margr1440
{\pard\f1\fs32\b Hello\par}
{\pard\f0\fs24 This is {\b bold}, {\i italic} and {\cf2 red}.\par}
{\pard\f0\fs24 Caf\'e9, \u8364\'80 5 and a brace: \{\par}
}
  1. 1{\rtf1 … }

    The outer group and version

    The whole document is one group, and it must start with {\rtf1. The 1 is the major version; every version from 1.0 to 1.9.1 writes 1.

  2. 2\ansi\ansicpg1252

    Character set and code page

    Bytes written as \'hh are read in this code page, here Windows-1252 (Western European). Text in other alphabets uses \u escapes instead.

  3. 3\deff0

    The default font

    Font number 0 from the font table, used wherever no other font is set.

  4. 4{\fonttbl …}

    The font table

    Numbers each font and gives its family (\froman serif, \fswiss sans-serif, \fmodern monospaced) so a reader without that exact font can pick a similar one.

  5. 5{\colortbl;\red0…;\red200\green30\blue40;}

    The colour table

    A numbered list of colours. The empty first entry means automatic, so \cf2 (text colour 2) is the red one.

  6. 6{\info …}

    Document information

    Title, author and other properties, shown in File, Properties. Like DOCX metadata, it travels with the file.

  7. 7{\*\generator …;}

    An ignorable destination

    \* tells readers to skip the whole group if they don't recognise it. This is how newer features were added without breaking older readers.

  8. 8\paperw11906\paperh16838

    Page size and margins

    In twips, twentieths of a point: 11906 × 16838 is A4, and 1440 is one inch.

  9. 9{\pard … \par}

    A paragraph

    \pard resets paragraph formatting to the defaults and \par ends the paragraph. Line breaks in the file itself are ignored.

  10. 10\fs32\b

    Font size and bold

    \fs32 is 32 half-points, so 16 pt. \b switches bold on; \b0 would switch it off.

  11. 11{\b bold}

    A group for local formatting

    Formatting set inside braces ends at the closing brace, so only the word bold is bold.

  12. 12Caf\'e9, \u8364\'80, \{

    Special characters

    \'e9 is byte E9 in the code page (é). \u8364 is Unicode character 8364 (€), followed by \'80, the fallback for readers that don't understand \u. Braces and backslashes in the text are escaped as \{, \} and \\.

Under the hood

Control words, groups and destinations

A reader goes through the file one character at a time and keeps a current state: font, size, bold, colour, paragraph settings. Control words change that state, an opening brace saves it and a closing brace restores it. That's why {\b bold} only affects one word.

  • Control words are a backslash, lowercase letters and an optional number: \b, \fs24, \cf2, \li720. A space after a control word ends it and isn't part of the text.
  • Control symbols are a backslash and one other character: \~ for a non-breaking space, \- for an optional hyphen, \{ for a literal brace.
  • Destinations are groups whose content isn't ordinary text: the font table, the colour table, headers and footers, footnotes, document information, images. A destination that starts with \* can be skipped by readers that don't know it.
  • Fields hold things that are calculated, such as page numbers and hyperlinks: an instruction (\fldinst) and its last result (\fldrslt), which readers without field support display as is.
Common control words
Control wordMeaning
\parEnd of paragraph
\pardReset paragraph formatting
\line, \page, \tabLine break, page break, tab
\b, \i, \ul, \strikeBold, italic, underline, strikethrough (\b0 turns bold off)
\f1, \fs24, \cf2Font 1, 12 pt, colour 2
\ql, \qc, \qr, \qjAlign left, centre, right, justify
\li720, \fi-360, \sb240, \sa120Left indent, first-line indent, space before and after, in twips
\trowd, \cellx, \cell, \rowStart a table row, set a cell's right edge, end a cell, end the row
\s1Apply style 1 from the style sheet

Characters

Special characters, Unicode and images

RTF files are almost always pure ASCII. Every other character is written as an escape, in one of two ways:

  • \'hh: one byte in the document's code page, set by \ansicpg. In Windows-1252, \'e9 is é. Readers that assume the wrong code page show the wrong letters.
  • \uN: a Unicode character as a signed 16-bit decimal number, followed by a fallback for readers that don't know \u. \uc1 says the fallback is one character long, usually ? or the nearest code-page character. Characters beyond 65535, such as emoji, take two \u escapes (a UTF-16 surrogate pair), and numbers above 32767 are written as negatives: 🙂 is \u-10179?\u-8638?.

Images are stored inside a \pict group as hexadecimal text, with a control word for their format: \pngblip, \jpegblip, \emfblip or \wmetafile. Hex takes two characters per byte, so an image doubles in size: the 4,864-byte PNG in sample-image.rtf takes 9,728 characters. Word often stores a second, WMF copy of each picture for older readers as well, which is why RTF files with photos can be many times larger than the same document as DOCX.

On a Mac, TextEdit can't keep images in a plain .rtf. A document with pictures is saved as .rtfd, a folder (shown as one file) holding an RTF file and the images next to it. Zip it before emailing or uploading it.

Comparison

RTF vs DOCX, TXT, ODT and HTML

RTFDOCXTXTODTHTML
StructureText with control wordsZIP of XMLText onlyZIP of XMLText with tags
FormattingFonts, styles, tables, lists, imagesEverything Word can doNoneEverything LibreOffice can doThrough CSS
Still developedNo, last update 2008Yes (ISO/IEC 29500)Not applicableYes (ISO/IEC 26300)Yes (WHATWG)
Opens in a browserNo, it downloads or shows as codeNoYesNoYes
MacrosNoNoNoYesNo (but JavaScript)
Size with imagesLarge: images stored as hexSmall: compressedNo imagesSmall: compressedImages are separate files

In practice: use DOCX or ODT for documents you keep editing, PDF for final versions, and RTF when a program can only produce or accept RTF, or when the reader's word processor is unknown and the formatting is simple. For text without formatting, TXT or Markdown is simpler still.

Troubleshooting

Common RTF problems and how to fix them

  • It shows code like {\rtf1\ansi. The file opened in a plain-text editor, or a browser showed it as text. Open it in a word processor instead. If a word processor shows the code too, the file was saved as plain text with an .rtf name, and the code is part of the text.
  • The file is huge. Images are stored as hex text, often twice. Save it as DOCX, or remove and re-insert the images as compressed JPEGs before saving as RTF.
  • Letters are wrong (é instead of é). Some tool wrote UTF-8 bytes straight into the file instead of escaping them. RTF readers expect ASCII with \'hh or \u escapes.
  • Formatting is lost after saving as RTF. Word features newer than RTF 1.9.1, as well as some layout features, have no RTF form. Keep the DOCX as your master copy.
  • Images are missing in TextEdit. The pictures were in an .rtfd package and only the RTF file inside it was sent.
  • WordPad is gone. Microsoft removed WordPad, the RTF editor that came with Windows, starting with Windows 11 version 24H2. Use Word, Word for the web or LibreOffice instead.

How to

How to open, edit and convert an RTF file

  • Windows: Microsoft Word, or LibreOffice Writer for free. Older Windows versions still include WordPad.
  • macOS: TextEdit opens and saves RTF out of the box; Word, Pages and LibreOffice open it too.
  • Linux: LibreOffice Writer or AbiWord.
  • In a browser or on a phone: browsers can't render RTF. Google Docs opens it after upload to Google Drive and can download a document as RTF.
  • Convert to DOCX or PDF: in Word, File, Save As. On a server: soffice --headless --convert-to docx file.rtf (or pdf). On a Mac: textutil -convert docx file.rtf.
  • Convert to text or Markdown: soffice --headless --convert-to txt file.rtf, textutil -convert txt file.rtf on a Mac, or pandoc -f rtf -t markdown file.rtf with a recent pandoc. Test the result: in our tests pandoc 3.1.3 dropped some letters after \u escapes in sample-unicode.rtf, which LibreOffice read correctly.

Security

Is it safe to open an RTF file?

RTF can't contain macros, which makes it look harmless. But it can embed OLE objects (the \object and \objdata destinations hold another program's data as hex), and Word's RTF reader is complex old code. For years RTF was one of attackers' favourite ways into Office:

  • CVE-2017-0199. An RTF file, often renamed to .doc, contained a linked OLE object that made Word download an HTA file from the attacker's server and run it. Exploited in the wild in April 2017 before Microsoft's fix.
  • CVE-2017-11882. A memory bug in Office's old Equation Editor, reached through an equation object embedded in a document. Patched in 2017, it was still used in RTF email campaigns years later, and Microsoft removed Equation Editor from Office.
  • CVE-2023-21716. A heap corruption bug in Word's RTF parser, triggered by a font table with an excessive number of fonts. Rated 9.8 out of 10, it could be triggered just by previewing the file in the Preview Pane. Fixed in February 2023.

Keep Office updated and leave Protected View on for files from email and the internet. Be wary of a ".doc" attachment that is really an RTF file. Organisations that don't need RTF can block it with Office's File Block settings.

Free downloads

Sample RTF files to download

Free sample RTF files for testing converters, previews, parsers and uploads. Each one is pure ASCII, follows RTF 1.9.1 syntax and converts to PDF and text with LibreOffice.

sample-document.rtf · 5.0 KBDownloadOpen
Loading…

What's inside sample-document.rtf

RTF has no comment syntax, so the preview shows the source. Look for these parts in it, then open the file in a word processor to see the result.

  1. The header

    {\rtf1\ansi\ansicpg1252\deff0\uc1, then the font table, a colour table with five colours and a style sheet with Normal, heading 1 and heading 2.

  2. Document information

    Title, author (the fictional Ada Example), subject, keywords and creation date in the \info group, and a \*\generator destination.

  3. A footer with a page field

    {\footer …} with a PAGE field whose stored result is 1.

  4. Character formatting

    Bold, italic, underline, strikethrough, a text colour, a highlight, a monospaced font, a larger size, superscript and subscript, each inside its own group.

  5. Special characters

    Code-page escapes (\'e9), Unicode escapes for Polish, Greek, Japanese and an emoji, the euro sign with a fallback, escaped braces and backslash, a non-breaking space, a tab and a line break.

  6. Lists

    Bulleted and numbered lists in the older \pntext and \*\pn form that WordPad and most readers understand.

  7. A table and a hyperlink

    A four-row table built from \trowd, \cellx, \cell and \row, with a shaded header row, and a HYPERLINK field back to this page.

All sample RTF files

  • Formatted sample document

    sample-document.rtf · 5.0 KB (5,103 bytes)

    An A4 document with headings from a style sheet, character and paragraph formatting, Unicode, lists, a table, a hyperlink, a footer with a page number and document properties.

    • Testing converters and previews
    • Learning RTF control words
  • Minimal RTF file

    sample-minimal.rtf · 130 bytes

    Three lines: the header, a font table and one paragraph with a bold word.

    • Parser smoke tests
    • Upload and content-type checks
  • Unicode test

    sample-unicode.rtf · 1.6 KB (1,665 bytes)

    Greetings in 13 languages, including right-to-left Arabic and Hebrew, plus emoji as surrogate pairs and maths symbols, all written as \'hh and \uN? escapes.

    • Checking how readers handle `\u` escapes and fallbacks
    • Finding encoding bugs in converters
  • RTF with an embedded PNG

    sample-image.rtf · 10.5 KB (10,735 bytes)

    A 480 × 270 bar chart stored as a \pict\pngblip group: a 4,864-byte PNG written as 9,728 hex characters.

    • Testing image extraction
    • Seeing why RTF files with pictures are large
  • 1 MB RTF file

    sample-1mb.rtf · 1 MB (1,048,576 bytes)

    2,665 numbered paragraphs of formatted filler text, padded to exactly 1,048,576 bytes (1 MiB). LibreOffice lays it out on 255 pages.

    • Upload limits and timeouts
    • Converter performance

Ways to test with them

  • Upload limits: sample-1mb.rtf is exactly 1,048,576 bytes, so you can test a 1 MiB limit at the boundary.
  • Unicode handling: convert sample-unicode.rtf to text and compare each line with the PDF from LibreOffice. Missing letters or ? marks mean the converter mishandles \u escapes.
  • Conversion fidelity: convert sample-document.rtf to DOCX or PDF and check the table, both lists, the footer page number and the link.
  • Content type: served as application/rtf, most browsers download the file; if one shows {\rtf1 as text instead, check the type the server sent.

Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.

Put it online

Have an RTF file? Give it a link.

Drop an RTF document on 99helpers and it gets its own link. Browsers can't display formatted RTF, so visitors download it and open it in Word, LibreOffice or TextEdit; to have it read in the browser, upload a PDF version.

Questions

RTF files, frequently asked

What is an RTF file?

A Rich Text Format document: formatted text, with fonts, styles, tables and images, written as plain text with control words. Almost every word processor can open it.

How do I open an RTF file?

Double-click it to open it in Word, LibreOffice Writer or, on a Mac, TextEdit. Google Docs opens it after you upload it to Google Drive.

What's the difference between RTF and DOCX?

RTF is plain text with control words and hasn't changed since 2008. DOCX is a compressed package of XML files, Word's current format, and supports everything Word can do. DOCX files with images are much smaller.

What's the difference between RTF and TXT?

A TXT file holds only characters. RTF adds formatting such as fonts, bold, colours and tables, written as control words like \b inside the text.

How do I convert RTF to PDF or Word?

Open it in Word or LibreOffice and save or export it as DOCX or PDF. On a server, soffice --headless --convert-to pdf file.rtf does it without a window.

Is RTF still used?

Yes, though less than before. TextEdit uses it by default, many programs export reports and letters as RTF, and formatted copy and paste often travels as RTF. Microsoft no longer adds features to it.

Can an RTF file contain a virus?

It can't contain macros, but RTF files have carried exploits for Word bugs and embedded objects, such as CVE-2017-11882 and CVE-2023-21716. Keep Office updated and be careful with unexpected attachments.

Why does my RTF file show strange code?

It's opening in a plain-text editor or a browser, which shows the control words instead of applying them. Open it with a word processor such as Word, LibreOffice or TextEdit.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.