How To Cleanly Export From Google Docs to HTML

Google Docs is a powerful and feature-rich online cloud-centered word processing program brought to us by, of course, search giant Google. Although Docs does not have all the bells and whistles of Microsoft Word, the undisputed champion in the document creation arena, it is nonetheless good enough for nearly all word processing tasks and it has the advantage of being completely free and available on any web browser. However, Docs has one serious shortcoming: it is really bad at exporting HTML properly. In this article I will show you how to work around Docs’ limitation in this area and cleanly export a document from Google Docs to HTML.

How To Cleanly Export From Google Docs to HTML

Docs is a great tool for teams to collaborate on a single document. You can all add your bit and create some really great content. With version control and the ability to manage multiple inputs, Google Docs makes short work of collaborative projects. For most content, exporting into a different format is just a matter of Save As or copy and paste. For HTML things are a little more involved. Google Docs does have a native Export to HTML option but the code is often very messy. That means you have some work to do in order to clean it and make it ready for the web.

If you have spent days creating content for export for your blog or website, you’ve put in a lot of effort on styling. Doing a copy and paste isn’t going to cut it; you need to export as HTML to maintain most of that styling, and you want a clean export so that the resulting HTML page is readable and modifiable down the line.

Export from Google Docs to HTML

There are a couple of different ways to get a clean export of your Docs file to HTML. The most straightforward way is to use a script called GoogleDoc2HTML. There are also some web apps that will do a conversion for you. Both methods work well.


GoogleDoc2Html began as a tool created by Omar Al Zabir and was refined and improved upon by Jim Burch. It is a script you add to Google Docs to clean up HTML exports and it works well.

Here’s how to use it:

  1. Open the document you want to export in Google Docs
  2. Go to the Tools menu, select ‘Script editor.’
  3. This will open a new tab. In that tab, copy and paste the GoogleDocs2Html code from GitHub, overwriting the stub function that the script editor starts with.
  4. Navigate to File and Save as ‘GoogleDoc2Html’.
  5. Navigate to Run and select ‘ConvertGoogleDocToCleanHtml’.
  6. Select Review Permissions when the popup window appears. You may have to log in to your Google account.
  7. Click continue to grant the permissions.

The script will then clean up the HTML output from Google Docs and email you the results. The email should arrive within a couple of minutes but may take longer depending on the size of the document. The one thing you need to know about using GoogleDoc2Html is that it is a single use script. It will clean up and export a document for you but you will need to repeat the entire process every time you want to use it.

HTML Cleaner

If styling is less of an issue, websites such as HTML Cleaner, HTML Tidy, HTMLCleanup and others can all help. These don’t interface directly with your Google Docs document; you will need to cut and paste the HTML and the apps will help you clean it up. There is a possibility that your formatting may be messed with a little but most of your layout should remain intact. When I tested it, headings and hyperlinks remained intact but a couple of bolded and italicized words were removed. They are still worth using though.

Whichever tool you use to export from Google Docs to clean HTML, you will need to manually check over the code to make sure it’s good. Even with this, it is much better than manually changing the markup within Docs before you export!

Need some more help with Google Docs? We have tutorials on putting a background image in Google Docs, how to organize your documents into folders in Docs, and how to add syntax-based formatting to code in Google Docs. And if Docs just isn’t getting it done for you, check out this guide to five alternatives to Google Docs.

3 thoughts on “How To Cleanly Export From Google Docs to HTML”

Paul says:
Not sure if this worked or not. The email with the HTML never was sent to me. I also do not have a File>Save As, but I did save it, and I ran the script… in theory it worked but it never arrived.

If it works, I very much appreciate the post. It is crazy that Google Docs does not have an export to HTML option… kind of basic and Google should know that of all companies.

John Bauer says:
Got an error “Limit Exceeded: Email Total Attachments Size. (line 35, file “Code”)”
Nico says:
Can’t find step 4 Am I the only one who doesn’t have File > Save as?

Comments are closed.

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.

Todays Highlights
How to See Google Search History
how to download photos from google photos