Manatee

An RTF file that opens as a wall of code on a Mac

When an RTF file opens as a screen of backslashes and braces starting with {\rtf1, you are looking at the formatting instructions instead of the formatted text. Usually the words are all still there. Either the app is set to show the code (TextEdit has a setting for exactly this), the app does not understand rich text at all, or the file itself has been saved with the code as its content. A ten-second test with Quick Look tells you which, and each case has a quick fix.

First, find out whether it is the app or the file

Rich Text Format is plain text with instructions mixed in. {\b bold} means “show this word in bold”; \par means “start a new paragraph”. An app that understands RTF follows the instructions and hides them. An app that does not simply shows them.

Select the file in Finder and press the Space bar.

  • Quick Look shows formatted text. The file is healthy. The app you opened it with is the problem. Go to the first two causes below.
  • Quick Look also shows the code. The problem is in the file. Look at its name: a file ending in .txt is the third cause, and a file ending in .rtf is the fourth.

Cause 1: TextEdit is set to show RTF code

TextEdit can deliberately open RTF files as raw code, which is handy for people who write RTF by hand and baffling for everyone else. If the setting was switched on at some point, every RTF opens that way.

  1. Open TextEdit and choose TextEdit, Settings (Preferences on older versions of macOS).
  2. Click the Open and Save tab.
  3. Under When Opening a File, untick Display RTF files as RTF code instead of formatted text.
  4. Close the RTF file and open it again.

TextEdit’s Open dialog has a similar switch. If you opened the file with File, Open, click Options at the bottom of that dialog and make sure Ignore rich text commands is not ticked.

Cause 2: the app does not read rich text

Code editors, plain text editors, Terminal and many web forms treat every file as plain text, so an RTF shows up as code. Nothing is wrong with the file; it simply needs to be opened somewhere that understands it, or converted into what the destination expects.

  • To read or edit it on your Mac, open it in TextEdit or Pages. Right-click the file, choose Open With, and pick one.
  • To send it to someone whose software shows code, convert it to DOCX, which word processors everywhere open. How to convert RTF to DOCX covers the TextEdit route in detail.
  • To paste the words into a form or a system that only accepts plain text, convert it to TXT, which keeps the words and drops the formatting.

Cause 3: an RTF saved with a .txt name

If the file ends in .txt but its first characters are {\rtf1, it is a real RTF file wearing the wrong extension. The Mac trusts the name, opens it as plain text, and shows you the code.

The fix is to correct the name. If Finder hides extensions, choose Finder, Settings, Advanced, and tick Show all filename extensions first. Then click the file, press Return, change .txt to .rtf, and confirm when Finder asks whether to use .rtf. Double-click it, and it opens formatted.

If you would rather leave the name alone and get a DOCX out of it, the built-in textutil command can be told to read the file as RTF regardless of its extension:

textutil -format rtf -convert docx "notes.txt" -output "notes.docx"

For files that arrived with no extension at all, a file with no extension that will not open walks through identifying them.

Cause 4: the code was saved as text inside the document

This one happens when someone opens an RTF as code (because of cause 1 or 2), then saves it again as RTF. The code becomes the document’s content, wrapped in a second layer of RTF. Every app, including Quick Look, now faithfully shows the code, because that is genuinely what the document says.

The good news is that the original is sitting inside, intact. Unwrap it by converting the outer layer to plain text and saving the result with an .rtf name. In Terminal, type cd and a space, drag the file’s folder onto the window, press Return, and run:

textutil -convert txt "report.rtf" -output "report-fixed.rtf"

Open report-fixed.rtf and it should appear with its original formatting. The same thing works in TextEdit: open the file, choose Format, Make Plain Text, save it, then rename the saved file so it ends in .rtf.

If the fixed file still shows code, it was wrapped more than once. Run the command again on report-fixed.rtf, with a new output name.

Converting RTF so it opens anywhere

Once the file opens properly on your Mac, converting it is the reliable way to stop the problem recurring at the other end. For one file, TextEdit’s File, Save As with File Format set to Word 2007 Format (.docx) is enough. For a folder, textutil -convert docx *.rtf handles everything in one line.

Manatee does the same from Finder without Terminal, and handles a mix of document types at once:

  1. Open Manatee and choose Convert, or drag the files onto its menu bar icon.
  2. Drop in the RTF files, along with any DOC, RTFD, HTML or webarchive files that need the same treatment.
  3. Choose DOCX to keep the formatting, or TXT for the words alone.

Each converted file is written next to its original, which is never changed, and nothing leaves your Mac. Manatee is free for 24 hours with every feature, then $9 once. It does not convert Pages documents; opening a .pages file without iWork covers those.

Questions

The RTF arrived as a folder full of files. What happened? That is an RTFD, a TextEdit document with images, which is really a folder. Sent through a service that does not understand Mac packages, it arrives opened up. The text is in the file called TXT.rtf inside. How to convert an RTFD to RTF or DOCX shows how to turn it back into one file.

Is any of my text lost when it shows as code? Usually not. Every word is still there between the instructions, and you can read it if you have to. Opening the file in the right app, or unwrapping it as in cause 4, brings the formatting back.

What if the document shows odd symbols rather than code? That is a different problem, usually a text encoding mismatch or a damaged document. A document that opens full of strange symbols covers it.