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.
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:
- Open the document you want to export in Google Docs
- Go to the Tools menu, select ‘Script editor.’
- 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.
- Navigate to File and Save as ‘GoogleDoc2Html’.
- Navigate to Run and select ‘ConvertGoogleDocToCleanHtml’.
- Select Review Permissions when the popup window appears. You may have to log in to your Google account.
- 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.
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 .