How to Use the macOS textutil Command to Convert Documents in the Terminal

The Hassle of Document Conversion

If you receive a Microsoft Word document (.docx) and need to quickly convert it to a standard text file (.txt) or an HTML page, the standard workflow is tedious. You have to open Microsoft Word (or Apple Pages), wait for the application to load, open the file, click “File,” click “Export,” choose the format, and save it.

If you need to do this for twenty files, the graphical interface becomes a massive bottleneck.

macOS contains a powerful, built-in terminal command called textutil. This utility hooks directly into the core text-rendering engine of macOS, allowing you to instantly convert documents between various formats (TXT, HTML, RTF, RTFD, DOC, DOCX) directly from the command line, without ever opening a word processor.

Step 1: The Basic Format Conversion

Open the Terminal application (found in Applications > Utilities).

The syntax for textutil requires the -convert flag, followed by the target format, followed by the file you want to convert.

Let’s say you have a file named Report.docx on your desktop, and you want to strip away all the formatting and convert it into a plain text file.

Navigate to your desktop:

cd ~/Desktop

Run the conversion command:

textutil -convert txt Report.docx

Press Enter. The command executes silently. Within a fraction of a second, a new file named Report.txt will appear on your desktop. The original file remains untouched.

Step 2: Converting to HTML

One of the most useful features of textutil is its ability to generate clean HTML code from formatted documents. This is invaluable if you are writing blog posts in a word processor and need to quickly generate the HTML tags for bold text, italics, and paragraphs.

textutil -convert html Report.docx

This generates a Report.html file. If you open this file in a text editor, you will see that textutil has automatically wrapped your paragraphs in <p> tags and converted your styling into standard CSS.

Step 3: Batch Converting Multiple Files

The true power of the terminal lies in automation. Because textutil accepts wildcard characters (*), you can convert an entire folder of documents in a single command.

Let’s assume you have a folder containing fifty .rtf (Rich Text Format) files, and you need to convert all of them into Microsoft Word .docx files.

Navigate to that folder in the terminal, then type:

textutil -convert docx *.rtf

Press Enter. The command will rapidly process every single RTF file in the directory, generating fifty brand new DOCX files alongside them. What would have taken an hour manually takes three seconds.

Step 4: Merging Multiple Documents (-cat)

Beyond simple conversion, textutil can also concatenate (merge) multiple documents together into a single, massive file.

If you have three separate text files (Chapter1.txt, Chapter2.txt, Chapter3.txt) and want to combine them into a single Microsoft Word document, you use the -cat flag.

The syntax is slightly different. You specify the format, the output file name, and then list the input files.

textutil -cat docx -output FullBook.docx Chapter1.txt Chapter2.txt Chapter3.txt

This takes the raw text from all three files, stitches them together in order, and wraps them in a new .docx container.

Step 5: Stripping Metadata (-strip)

Word documents and rich text files often contain hidden metadata, such as the author’s name, the creation date, and the company name. If you are sharing a document publicly and want to sanitize this metadata for privacy reasons, textutil can help.

You can use the -strip flag to remove this metadata during a conversion. (Note: This is most effective when converting to RTF or HTML, as standard TXT does not support metadata anyway).

textutil -convert rtf -strip Report.docx

This creates a new RTF file with the text content preserved, but the hidden author attributes removed.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.