markdown-preview-export
Export your Markdown preview from Visual Studio Code exactly as you see it (styles, images, etc) to an HTML file. Open the result in your browser to print, save as PDF, or share.
Features
- Export Markdown Preview as HTML: Export the current Markdown preview (not just the raw Markdown) as a styled HTML file (WYSIWYG)
- Embed Local Images: Include local images directly in the exported HTML by default, so the file is easier to share.
- Cancel Export: The logic is non-deterministic since it relies on other extensions or customizations you may have that alter the markdown preview. There's a potential for problems, so you can cancel the export by clicking the status bar button.
Usage
- Open a Markdown file and preview it (
Ctrl+Shift+V or Cmd+Shift+V).
- Click the Export Preview button in the preview title bar, or run the
Markdown: Export Preview command from the Command Palette.
- By default, the extension saves the HTML file to your system's temporary folder (e.g.,
C:\Users\<user>\AppData\Local\Temp\markdown-preview.html on Windows).
- After export, use the notification actions to open the file in your browser, reveal it in your file explorer, or copy the saved file path.

Note!
If you already had a markdown preview open when you install or enable this extension, you'll need to close and re-open it or open another to make the menu option visible. From then on it should always be visible.
Commands
Markdown: Export Preview (markdown.exportPreview): Export the current Markdown preview as HTML.
Markdown: Cancel Markdown Preview Export (markdown.cancelPreviewExport): Cancel an ongoing export operation.
Requirements
No additional requirements or dependencies.
Extension Settings
markdownPreviewExport.embedLocalImages: Embed local images as data URIs in the exported HTML. Remote and existing data URI images are left unchanged. Defaults to true.
markdownPreviewExport.outputMode: Controls how exported HTML files are saved. Use temp for the system temporary folder, besideMarkdown to save next to the current Markdown file, or ask to choose each export location. Defaults to temp.
Limitations
- Only exports the current preview. If the preview is not open, the command will not work.
- When
markdownPreviewExport.outputMode is temp, the exported HTML is saved to your system's temp directory using the same name and will be overwritten with each export.
How it works
The extension hooks into the Markdown preview rendering process, captures the fully rendered HTML (including styles and theme), and writes it to a file. It primarily uses VS Code's public markdown.api.render API to render the document, with an automatic fallback to a legacy private API for older VS Code builds. Because the fallback path relies on VS Code internals, it could break in future releases.
Release Notes
0.0.3
- Fixed compatibility with current VS Code by using the public
markdown.api.render API, with a fallback to the legacy private API for older builds.
- Added
markdownPreviewExport.embedLocalImages setting to embed local images as data URIs in exported HTML (enabled by default).
- Added
markdownPreviewExport.outputMode setting to control where exported files are saved: system temp folder (temp), next to the Markdown file (besideMarkdown), or prompted each time (ask).
- Improved post-export notification with actions to open the file in your browser, reveal it in the file explorer, or copy its saved path.
0.0.2
- Bug fixes for edge cases during installation
0.0.1
- Initial release: Export Markdown preview as HTML, matching VS Code theme, with quick open in browser.
| |