Overview
GDocs-Me-Up is a Node.js script for exporting Google Docs to plain HTML and CSS with high visual fidelity. It uses detailed styling data from the Google Docs API to preserve formatting that simpler exports may lose, making it suitable for offline or self-hosted document copies.
The exporter adds CSS that reflects the source document while neutralizing browser defaults that could change its appearance. Exported content is wrapped in a semantic main-content element so separate navigation can remain outside the primary document landmark.
Key Features
- Maps title, subtitle, and six heading levels to HTML headings or custom classes.
- Preserves paragraph spacing, margins, indentation, alignment, and line spacing.
- Handles right-to-left paragraphs and lists with adjusted direction and alignment.
- Recreates tables, nested bullet lists, numbered lists, and tables of contents.
- Exports inline and positioned images at document dimensions while preserving crops and fitting page width.
- Collects fonts used by the document and includes the corresponding Google Fonts stylesheet.
Image Handling
JPEG images are converted to high-quality WebP. Opaque photographic PNG files can also become WebP when doing so reduces their size by at least 20%, while transparent and graphic PNG files are compressed losslessly. Other recognized image formats retain their actual extensions.
Setup and Use
The exporter requires Node.js 20.9 or later, the project dependencies, and a Google Cloud service-account key with permission to read the document. The Docs API and Drive API must be enabled, and the source document must be accessible to the service account.
Run the script with the Google Docs document ID and an output directory. The service-account key can be placed beside the script or selected through the supported key-file environment setting.