How to Keep Syntax Highlighting When Pasting Code into OneNote
Question details
User needs a way to paste programming code from a code editor into OneNote without losing the colors and formatting of the syntax highlighting.

- Product
- OneNote for Windows 10
- Device & OS
- Windows 10
- Scenario
- Copying source code from a development environment (like Code Composer Studio) and pasting it into a notebook for documentation.
- Observed behavior
- The syntax highlighting and rich formatting are stripped out, leaving only plain, unformatted text when pasted into OneNote.
Ensure your specific code editor supports copying text with rich formatting (RTF or HTML). If the editor only copies plain text to the clipboard, no destination app will be able to display the syntax colors.
Use Microsoft Word or WPS Writer as a Formatting Bridge
Paste the code into a robust word processor first to lock in the clipboard formatting, then transfer it to OneNote.
OneNote's clipboard processor sometimes struggles to interpret the raw HTML/RTF data coming directly from certain IDEs like Code Composer Studio. Word processors have more advanced clipboard handling and can reliably interpret these formats.
Highlight your code in your programming editor and press Ctrl + C to copy it.
Open a new blank document in Microsoft Word or WPS Writer. Right-click the page and select 'Keep Source Formatting' under the Paste Options to paste your code.
Select the newly pasted and colored code in the word processor, press Ctrl + C to copy it again, and then paste it directly onto your OneNote page.

Check OneNote Paste Settings and App Version
Verify that your OneNote paste defaults aren't stripping formatting and that the app is fully updated.
Try WPS Writer for Better Code Documentation
If Microsoft Office applications are causing clipboard headaches, WPS Office provides a lightweight, seamless alternative. WPS Writer perfectly retains rich text formatting, including syntax highlighting from popular code editors, making it an excellent tool for developers creating technical documentation.
- 1. Install WPS Office: Download and install the free suite from the official WPS website.
- 2. Copy the Code: Highlight and copy the target code from your preferred code editor.
- 3. Paste into WPS Writer: Open a new Writer document and press Ctrl+V. The syntax highlighting will be preserved flawlessly.

Frequently Asked Questions
Why does OneNote sometimes paste code as plain text?
This usually happens if the source IDE places plain text on the system clipboard rather than HTML/RTF data, or if OneNote's default paste setting is configured to 'Keep Text Only'.
Can I use a OneNote add-in to format source code directly?
Yes. If your editor won't export colors properly, you can use third-party OneNote add-ins like NoteHighlight or OneMore to generate syntax highlighting natively inside OneNote.
Does pasting into OneNote for Web retain formatting better?
Because web browsers process clipboard HTML differently than Windows desktop apps, pasting into the OneNote Web version sometimes bypasses desktop clipboard bugs and retains colors perfectly.




