The Problem
Microsoft published RTF in 1987 and it never went away. It is still a "Save As" option in Word, it is what TextEdit produces on macOS, and older government and legal systems use it widely. Yet many parsing libraries either skip RTF or run a 200 MB LibreOffice install to read a 50 KB form.
soffice --headless to read an RTF takes about 2 GB of memory and ~3 seconds to start, and it tends to leak file handles in long-running services. AILANG Parse reads the same file in <50 ms without starting another program.How It Works
The parser reads the RTF source one character at a time. It follows the nested { } groups, recognizes control words (such as \par) and control symbols, and decodes Unicode and CP1252 escapes. The output uses the same block format as every other AILANG Parse format: one TextBlock per paragraph.
# Parse an RTF file from the CLI
docparse contract.rtf
# Or via API
curl -X POST https://docparse.ailang.sunholo.com/api/v1/parse \
-F "filepath=@contract.rtf" \
-F "outputFormat=markdown" \
-F "apiKey=YOUR_API_KEY"
Encoding Support
RTF has two ways of writing non-ASCII characters. AILANG Parse decodes both.
| Escape | Meaning | Example | Decoded |
|---|---|---|---|
\uNNNN? | Signed 16-bit Unicode code point (RTF 1.5+) | K\u248?bsaftale | Købsaftale |
\'XX | CP1252 (Windows-1252) byte in hex | 100\'80 | 100€ |
\\ \{ \} | Literal backslash/brace | 50\% off | 50% off |
\tab \cell | Tab character / table cell separator | Name:\tab Jane | Name:[TAB]Jane |
\par \row | Paragraph break | line 1\par line 2 | Two TextBlocks |
CP1252 (Windows-1252) bytes in the 0x80–0x9F range are translated to the right characters: euro sign (0x80 → €), smart quotes (0x91–0x94 → ' ' " "), em/en dashes (0x96–0x97 → – —), ellipsis (0x85 → …), trademark (0x99 → ™) and the rest of the punctuation Windows puts in that range. Bytes 0xA0–0xFF map directly to Unicode U+00A0–U+00FF.
What Is Skipped
An RTF file mixes the document text with header tables, which RTF calls "destinations": fonts, colors, stylesheets, list definitions, generator strings, theme data. The parser skips them whole, so none of it ends up in the extracted text. That includes groups nested inside a skipped group, such as {\*\panose ...} inside \fonttbl.
\fonttbl,\filetbl,\colortbl,\stylesheet,\listtable,\listoverridetable— definition tables\info,\generator,\themedata,\latentstyles,\datastore— document information and theme data\pict,\shppict,\nonshppict— embedded image data (not extracted)\field,\fldinst,\fldrslt— field codes, including the code behind hyperlinks\bkmkstart,\bkmkend,\panose,\xmlnstbl— bookmarks and other markers- Any
{\*\foo …}— the RTF specification marks starred destinations as optional, and the parser skips them
Example Output
Each \par ends a TextBlock. Form fields separated by tabs stay in one block with \t between them, which keeps the row layout when the text is converted to Markdown or HTML.
{
"blocks": [
{"kind": "TextBlock", "style": "normal", "text": "Sample RTF Document"},
{"kind": "TextBlock", "style": "normal", "text": "Danish words: Købsaftale, økonomi, smørrebrød, fjærkræ, ål."},
{"kind": "TextBlock", "style": "normal", "text": "French phrases: café au lait, première classe, naïveté."},
{"kind": "TextBlock", "style": "normal", "text": "Currency: 50£ pounds sterling, 100€ euro, 250¥ yen, copyright © 1999."},
{"kind": "TextBlock", "style": "normal", "text": "Smart quotes: “like these” and ‘these’."},
{"kind": "TextBlock", "style": "normal", "text": "Name:\tJane Doe"},
{"kind": "TextBlock", "style": "normal", "text": "Email:\tjane@example.com"}
]
}
Use Cases
Government & Legal Forms
Danish Købsaftale (real-estate purchase agreements), French CERFA tax forms, UK court filings, US municipal templates. These often come as .rtf because every operating system since the 1990s can open them without a converter. Parse them in bulk without installing Word.
Legacy ERP & CRM Exports
Older SAP, Oracle and JD Edwards modules export reports as RTF. So do Salesforce mail merge templates and certain Dynamics flows. With a parser that does not need Office, batch jobs no longer need a Windows machine.
Email & MailMerge Pipelines
Outlook still saves drafts as RTF in message/rfc822 attachments. Mass-mailing platforms (Constant Contact, Mailchimp legacy lists) accept RTF templates. Parsing them lets you load past campaigns into current analytics tools without retyping.
Document Migration & Archival
Government and academic archives often hold decades of .rtf files alongside .doc and .docx. AILANG Parse reads the .rtf and .docx files. It does not read the older binary .doc format.
RAG over Heterogeneous Corpora
Your knowledge base has DOCX from 2018, PDF from 2024, EML from 2012 and RTF from 2003. One parser API that reads all of them, gives the same result every time and returns the same block format is worth more than a small quality gain on any single format.
TextEdit & Pages Exports
macOS users often save notes as RTF, TextEdit's default rich-text format. Pages and Numbers export to RTF to share with other platforms. If your product accepts uploads from Mac users, you will meet RTF sooner or later.
Try It
RTF is one of 17 supported input formats. Parsing uses no AI model and no other program, and the same file always gives the same result.
# CLI
docparse contract.rtf --convert contract.md
# API
curl -X POST https://docparse.ailang.sunholo.com/api/v1/parse \
-F "filepath=@contract.rtf" \
-F "outputFormat=markdown" \
-F "apiKey=YOUR_API_KEY"
Parse in Browser API Reference
Frequently Asked Questions
Do I need LibreOffice or Word installed to parse RTF?
No. AILANG Parse reads RTF itself. It does not run LibreOffice (soffice), Word or antiword. It runs in the browser (using WebAssembly) as well as on the server.
Does it handle non-ASCII characters like Danish or German?
Yes. \uNNNN Unicode escapes and \'XX CP1252 hex escapes are both decoded. Windows-1252 bytes 0x80–0x9F are translated to the right Unicode characters (euro sign, smart quotes, em dash and so on).
What does the parser skip?
Header groups, which RTF calls destinations (\fonttbl, \colortbl, \stylesheet, \info, \listtable, \themedata, \panose, picture data, fields, etc.) are skipped whole. Any starred destination ({\*\foo …}) is skipped too, with everything nested in it. Formatting control words (\b, \i, \fs, \cf, …) are recognized and ignored, so bold, italic, font size and color are not kept.
Are tables preserved?
Tables are flattened: \cell becomes a tab and \row becomes a paragraph break. The data is kept but the grid is not.
What about embedded images (\pict)?
Images are not extracted. Image data (the \pict destination) is skipped. If you need images extracted from RTF, file a feature request.
Where does RTF still show up in real workflows?
Government forms (Danish Købsaftale, French CERFA), legal templates, court filings, ERP exports, older MailMerge pipelines, and any system that needs a format Word and TextEdit both render without a converter. RTF is still a default "Save As" option in Microsoft Word.