Best way to add syntax highlighting to a Word document in 2025

Microsoft Word still has no native syntax highlighting in 2025. This guide compares every method available — and tells you which ones are worth using.

Quick comparison

MethodColoursIndentationEditableSpeed
Screenshot Fast
Word Code Style ~Medium
VBA Macro ~Slow
Word Add-in Medium
IDE Paste Special Medium
FormatCodeVery fast

Method breakdown

Method 01

Screenshots

Screenshot your IDE and paste the image into Word.

Pros: Quick, accurate colours, no setup.

Cons: Not text — can't be searched or copied. Blurry at print scale. Any update requires a new screenshot.

OK for quick, single-use docs
Method 02

Word's built-in Code style

Home → Styles → Code gives you a monospace font — no colours at all.

Not recommended for real documentation
Method 03

VBA macros

Write a Word macro (Alt+F11) that applies character formatting to code. Several open-source scripts exist.

Cons: Requires enabling macros (security risk), hard to maintain, limited language support, breaks across Word versions.

Viable for IT departments with specific needs
Method 04

Word Add-ins (Microsoft AppSource)

A few code highlighting add-ins integrate directly into Word 365.

Cons: Most require paid subscription. Quality and language support varies. Requires Word 365.

Good if you're on Word 365 and paste code daily
Method 05

VS Code → Paste Special → HTML Format

VS Code copies rich HTML. In Word: Edit → Paste Special → HTML Format.

Why it fails: VS Code uses CSS classes (.mtk5 { color:#569cd6 }). Word ignores stylesheets — only reads inline style="". Result: no colours. Indentation also collapses because regular spaces are used.

Looks promising but doesn't actually work
Method 06 — Recommended

Online formatters (FormatCode)

Purpose-built tools that generate Word-compatible HTML with inline styles, non-breaking spaces and solid opaque colours.

Pros: Free, no install, 30+ languages, works with Word, Google Docs, PowerPoint and Outlook.

Best overall — recommended

Why inline styles beat CSS classes in Word

The indentation difference is the same: VS Code uses regular spaces that Word collapses; FormatCode uses \u00A0 non-breaking spaces that Word preserves as content.

The rule: For code to look correct in Word you need (1) inline style attributes, (2) non-breaking spaces for indentation, and (3) solid hex colours with no opacity. FormatCode generates all three.

Add syntax highlighting to Word right now

Free. No signup. Works for all languages. Try it in 30 seconds.

Open FormatCode →

Related guides