Editing a Markdown File in Google Docs

David Singer
3 min readSep 13, 2021

When recently working on a markdown file, I needed a simpler way to quickly format and manipulate the whole document to suit my specific needs. I think it would have taken a considerable amount of time if doing it in a markdown editor like StackEdit or Dillinger. While these tools are excellent at what they allow you to accomplish, the functions I needed were limited to a paid option or simply not available in those tools.

I happened across an easier method to edit the document and wanted to share what I found. In order to import a markdown (.md) file into Google Docs, I used the Pandoc tool. Pandoc is a universal document converter that converts files from one markup format into many other formats, as noted in the image below.

Image displaying the format types pandoc can convert. https://pandoc.org/

Import Options

I found multiple ways to convert a markdown file and import it into Google Docs for editing.

Option 1

The first option is to use Pandoc locally to convert the markdown file to docx and then import it to Google Docs using the Google Drive API.

Option 2

The second method also locally converts the file and then accomplishes the task using the Google Drive web interface itself.

Conversion

  1. First, let’s convert the local markdown file to ODT (or another interim format) using the following pandoc command in Powershell. The standard format for the command looks like this:
    pandoc [input format] ==reader==> [Pandoc AST] ==writer==> [output format]
  2. So, my command looks like this:
    pandoc file.md -f markdown -t odt -s -o file.odt
  3. Now, move the file.odtto your local Google Drive folder (if using the Google Drive Desktop) or upload the file.odt into your Google Drive.
  4. Once the upload is complete, right-click on the file.odt (in the web version of Google Drive) and select “Open WithGoogle Docs.” Google Drive will now create and open a new Google Doc, with the contents matching the file.odt.

Export

When the changes are complete in Google Docs, I export the edited file using the “Docs to Markdown” (GD2md-html) tool. This plugin converts the Google Doc to a simple, readable Markdown or HTML file.

To export the open document, follow the steps below.

  1. Select Add-ons > Docs to Markdown > Convert.
  2. Select the text to convert (the default setting selects the entire document).
  3. Next, click the Markdown or HTML button in the sidebar.
  4. Finally, cut-and-paste the converted output from the sidebar and paste it into a .md document of your choosing.

That’s it! This is an easy method to import/export a Markdown document from one format to another. Thanks for reading!

Note: I am sure the follow-up comments below may offer more and better options for accomplishing this task. :D

--

--

David Singer

I am a g33k, Linux blogger, developer, student, and writer. My passion for tech drives my hunt for all the coolz. I write to expose, explore, and explain me...