Converting Medium posts to Markdown

  • Post by Lan
  • Aug 26, 2020

I started blogging on Medium, but recently built my own website using Hugo, which is a static site generator written in Go and supports markdown content files (.md). Apparently, I need a solution to export my Medium’s articles to the Markdown language. There are several tools that allow you to do so.

1. Chrome markdown extension

This Chrome Extension is supposed to convert a Medium post into Markdown fast and fairly easy. Unfortunately it does not work for me. From reviews of users, it seems that even if the extension works, it makes a number of formatting errors that require some manually corrections. And in case you have medium articles with multiple images, it only considers the first image and converts into markdown and ignores the rest.

2. Command Line Interface tool

The medium-2-md is a CLI tool which takes a directory containing Medium posts’ HTML files and converts them into markdown. It also downloads all the images used in your Medium’s posts and also adds a rich front matter to these converted markdown files so that the markdown files are ready for use.

Step 1.

  • Install node.js
  • Install medium-2-md package by running the following command

npm i -g medium-2-md

Step 2. Export your Medium posts to html files.

  • Go to, scroll to Download your information. Click the download zip button. Now you should see a file in your download folder.
  • Extract the .zip file. Now in the medium-export directory, there shoud be a sub-directory called posts
  • Copy the path of this posts directory.

Step 3. Run the following command in your command interface:

medium-2-md convertLocal "<path of the post directory>" -dfi

Where <path of the post directory> is the path we copied in step 2. In my case this is C:\Users\lcu1812\medium-export\posts.

The flags -dfi converts drafts (d) as well, adds front matter (f) on top of the markdown file and downloads all images (i) to a local img sub-directory.

And Voila. All the markdown files of your medium post’s HTML files are now stored in a sub-directory in the posts directory called md_<a_big_number>

This tool saves me hell of a lot of time when converting all my Medium’s posts to markdown. There are a few things I still need to manually take care of though. My laptop is a window operating system which uses backslashes for paths meanwhile all the paths created in the markdown (.md) file for all the images use forward slashes. So a manually convert of backslashes to forwar slashes is needed.

It happened to me that when I first tried medium-2-md, I got the following error message:

EINVAL: invalid argument, mkdir ‘C:\\Users\\lcu1812\\’C:\\Users\\lcu1812\\medium-export\\posts’\\md\_1598004248526'

That’s the result of how Windows command prompt handles single quotes (macOS and Linux won’t have this problem). If you have the same problem, you can try one of the following commands. They should all work:

medium-2-md convertLocal C:\Users\lcu1812\medium-export\posts -dfi

medium-2-md convertLocal C:\\Users\\lcu1812\\medium-export\\posts -dfi

medium-2-md convertLocal “C:\\Users\\lcu1812\\medium-export\\posts” -dfi

More details of the package are available at this Git Repository medium-2-md GitHub repository.