Formatting Issues

How to Fix Word Pasting Code Without Syntax Colors

Tauseeq MagsiTauseeq Magsi Oct 26, 2026 868 views

Question details

The user needs to paste programming code from a website into a document while retaining the original syntax highlighting, indentation, and capitalization.

How to Fix Word Pasting Code Without Syntax Colors
Product
Microsoft Word
Device & OS
not provided
Scenario
Copying code snippets from programming websites (such as W3Schools) and pasting them into a Word document.
Observed behavior
The pasted text appears as plain black text, losing all its original HTML syntax colors, indentation, and specific formatting.
Before you start

Ensure your clipboard settings allow rich-text copying and check that your document is not currently restricted to plain-text formatting.

Solution 1Recommended

Use the Keep Source Formatting Paste Option

Force Word to retain the original HTML formatting and colors attached to your clipboard data.

By default, Microsoft Word might adjust pasted text to match the destination style. Using the 'Keep Source Formatting' option ensures that Word attempts to preserve the exact colors, bolding, and indentation provided by the website.

1
Copy the Code

Highlight the desired code on the programming website and press Ctrl + C (or Cmd + C on Mac) to copy it.

2
Access Paste Options

Right-click on the exact spot in your Word document where you want to insert the code.

3
Select Keep Source Formatting

Under the 'Paste Options' menu, click the icon that features a paintbrush (Keep Source Formatting). Alternatively, paste the text using Ctrl + V, click the small clipboard icon that appears next to the pasted text, and select the 'Keep Source Formatting' icon.

Use the Keep Source Formatting Paste Option
Clipboard Data Matters: If the website only sends plain text to your clipboard, Word will not be able to retrieve the colors regardless of this setting.
Efficient Document Formatting

Use WPS Writer to Retain Code Syntax Colors

WPS Writer provides robust clipboard management, making it incredibly easy to paste programming code from websites while perfectly preserving the original syntax highlighting, indentation, and HTML layout.

  1. 1. Copy the Code Snippet: Select the formatted programming text from the website and copy it to your clipboard.
  2. 2. Open WPS Writer: Launch WPS Office and open your document in WPS Writer.
  3. 3. Paste with Source Formatting: Right-click your document, navigate to Paste Options, and choose 'Keep Source Formatting' to retain all syntax colors and indentation.
Seamlessly retain rich-text source formatting and colors from web pages.Fully compatible with Microsoft Word document formats (.docx, .doc).Lightweight application with an intuitive, familiar user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Word only offer the 'Keep Text Only' paste option for some web code?

This happens when the source website restricts its clipboard output to plain text. If the website's code block doesn't export HTML or rich-text data to your system's clipboard, Word has no color or formatting information to retrieve.

How do I set 'Keep Source Formatting' as my default paste option?

In Word, go to File > Options > Advanced. Scroll down to the 'Cut, copy, and paste' section. Change the setting for 'Pasting from other programs' to 'Keep Source Formatting' and click OK.

Why do some parts of a webpage paste with colors while others do not?

Different sections of a website can be developed using varying HTML structures. For instance, an interactive code terminal might use custom JavaScript that copies plain text, whereas a static preformatted text block might allow native HTML rich-text copying.