How to convert a dropped file into plain text
You drag a file onto a text box hoping for a clean line of text, and instead you get an attachment icon, a styled blob with a background colour, or nothing at all. Getting plain text out of a dropped file on a Mac is a common need with a few different answers, because “the file as plain text” can mean two separate things, and the method depends on which you want.
What “plain text” means here
Plain text is characters with no formatting: no font, no colour, no attachment wrapper, just the letters. When you say you want a dropped file “as plain text”, you usually mean one of two results. Either you want the file’s path written out as a string, so a terminal or a field can use its location. Or you want the words inside the file, poured out as unformatted characters, with any styling stripped off.
These are not the same, and knowing which you are after saves a lot of fiddling. The path is the address of the file. The contents are what the file holds. Both can be plain text, but you get them in different ways.
Why a dropped file often is not text
When you drag a file, macOS offers the destination several versions of it at once: the file reference, an icon, a preview, and sometimes text. The destination picks whichever it understands. A rich text document may grab the file reference and embed it as an attachment. A message box may attach it. A code editor usually takes the path. None of them is wrong. Each took the version it prefers, and only some of those versions are plain text.
So a dropped file becomes plain text only when the destination chooses a text version and does not dress it up. If you want a predictable result, you have to steer which version it takes.
Getting the path as text
For the location as plain text, the direct route is to copy the path rather than dragging the file. In Finder, select the file and hold Option, and “Copy” becomes “Copy as Pathname”, giving you a bare string like /Users/you/Documents/notes.txt. Paste that anywhere and it is plain text.
If you would rather drag, drag the file into a terminal window and the path appears as text with spaces escaped. Both give you the address in a form any text field can hold, with no icon and no attachment.
Getting the contents as plain text
For the words inside a file, stripped of formatting, open the file, select all with Command-A, and copy. Then, at the destination, use Paste and Match Style, Option-Shift-Command-V, instead of a plain paste. That drops the characters in and discards the original fonts, colours, and sizes, matching whatever the destination uses. It is the reliable way to move text between a formatted document and a plain field without dragging styling along.
For files that are already plain text, a straight open, select, copy, paste is enough, since there is no formatting to strip. The Match Style step matters when the source is a rich document, a web page, or a note with styling you do not want to carry over.
A shelf that hands over text
When the thing you keep needing is text at the drop, a staging spot that rewrites the hand-off is the calm way to do it. Ledge lets you drag a file up to the MacBook notch and set it on a shelf. When you drag it off, Ledge gives each destination the version it can use. Drop it into a plain text field and it hands over plain text. Drop it on a terminal and it hands over the path as text. Drop it on Finder and it moves the file instead.
That means you can pull a file onto the shelf without deciding yet what form you need, then drop it into a text field and get text, or into a terminal and get a path, from the same file waiting in the same place. The destination determines the representation, so a drop into a text box is text, not an attachment you then have to convert.
Quick reference
When you need a dropped file as plain text, decide first which text you want:
- The location: hold Option in Finder and choose Copy as Pathname, or drag the file into a terminal.
- The contents, unstyled: open, select all, copy, then Paste and Match Style at the destination.
- Either one, without thinking about it: set the file on a shelf and let the destination pick, so a text field gets text and a terminal gets a path.
Plain text is the lowest common denominator between apps, which is exactly why it is worth getting on purpose. Once you know whether you are after the path or the contents, the steps are short, and the result stops depending on which app happened to catch the drop.