Guide · VS Code

Markdown to PDF in VS Code

VS Code is excellent for writing Markdown, but it does not ship with a polished PDF exporter. Here are three practical ways to get from a .md file to a PDF.

Updated November 23, 2026 · Markdown2PDF by Hyperdyn

What VS Code can and cannot do out of the box

VS Code includes a Markdown preview, but the built-in preview is not a PDF exporter. You can print from some environments, yet the result depends on the browser or operating system and rarely gives you page-level style controls.

To get a predictable PDF you need one of three things: an extension that bundles a renderer, a task that calls a converter such as Pandoc, or an external tool that takes the Markdown and returns a PDF.

Option 1: A Markdown PDF extension

The most direct route is a VS Code extension that adds a PDF export command. Install the extension, open a Markdown file, run the export command from the Command Palette and choose an output location.

Extensions are convenient because they stay inside the editor. Their limitations are less predictable: CSS support, page-break control, font loading and large-document performance vary by extension and version. Check the extension’s current documentation before relying on it for a company template.

Option 2: A Pandoc task

If Pandoc is already installed, add a VS Code task that runs it against the current file. A task gives you a repeatable command and keeps the output next to the source.

pandoc input.md -o output.pdf

The command still needs a PDF engine and a template. It is a strong option for a repository with its own build conventions; it is heavy for a single document that just needs a clean page layout.

Option 3: Export through a browser converter

Keep writing in VS Code, then copy the Markdown or open the .md file in Markdown2PDF when you need the final document. The browser tool provides a page-accurate preview, visual style controls and a local export path.

  1. Finish the Markdown in VS Code and check that tables and code fences are valid.
  2. Copy the source or open the .md file in the browser editor.
  3. Choose a page style and inspect the page breaks.
  4. Export PDF or print-quality PDF.

This is a two-tool workflow, but it avoids installing a PDF renderer into the editor and gives you a better final-layout check. Start with the online Markdown editor.

Which option should you choose?

OptionBest forWatch out for
ExtensionQuick exports inside VS CodeInconsistent CSS, fonts and page breaks
Pandoc taskRepeatable repository buildsPDF engine, template and package setup
Browser converterVisual layout and one-off documentsManual copy or file open; no repository sync

A reliable .md to PDF workflow

Keep the Markdown source in the repository and treat the PDF as a build artefact. Before exporting, check relative image paths, repository-specific links and long code lines. Open the finished PDF and inspect at least the first page, a table-heavy page and the last page.

If the document has a required corporate template, a repository task is usually the better long-term answer. If the document is a report, proposal or handover that needs to look good today, the browser path is faster.

Frequently asked questions

How do I export Markdown to PDF in VS Code?

Install a Markdown PDF extension and run its export command, or configure a Pandoc task. You can also open the .md file in a browser-based converter and export from there.

Does VS Code have a built-in PDF exporter?

No. VS Code has a Markdown preview, but a PDF export normally requires an extension, a task or an external converter.

Can Markdown2PDF open a file from my VS Code project?

Yes. Open the .md file with the editor’s Open control or drag it into the writing area. The file is read in the browser and is not uploaded.