• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Dev Tips / Convert Markdown to Plaintext

Convert Markdown to Plaintext

Last updated on January 9, 2024 by Sal Ferrarello

I recently had to convert some markdown into plaintext and rather than use an online tool I wanted to do it locally. This is the solution I found.

Step 1: Install Pandoc

The Pandoc website has lots of options for installing Pandoc.

I’m on a Mac and use the Homebrew package manager, so I ran

brew install pandoc

Step 2: Convert the Markdown File

My markdown was in a file called myfile.md, so I ran the command

pandoc -f markdown -t plain myfile.md

This command outputs the plaintext to the standard output (the screen). We can capture this information in a file by appending > myfile.txt

pandoc -f markdown -t plain myfile.md > myfile.txt

Getting the Clipboard Involved

Since I’m on a Mac, I can use pbpaste to output the contents of the clipboard. This allows me to convert the contents of the clipboard with

pbpaste | pandoc -f markdown -t plain

Finally, if I want to copy the plain text into the clipboard I can use pbcopy to do this, so I run

pbpaste | pandoc -f markdown -t plain | pbcopy

which takes the markdown content in the clipboard, converts it to plain text, and copies the plain text back to the clipboard.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Dev Tips, Solution Tagged With: command line, Markdown

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in