How to Format Code in an Outlook Email


  1. Go to
  2. Paste your code
  3. Select your type (language)
  4. Select your style
  5. Click Highlight
  6. Copy/paste

The Challenge

Microsoft is always trying to “help” us by automatically formatting our text, creating lists whether or not we want them, and slowing down our machines until we apply system updates.

The same applies to Outlook. I don’t know about you, but when I see a code snippet, I like to see it formatted accordingly, not just blending in with everything else. Unfortunately, that’s somewhat difficult with Microsoft Outlook.

The Fix

A genius Stack Overflow user pointed the community in the direction of a tool originally created by Oleg Parashchenko called ToHTML. Here’s how to use it:

1. Navigate to

2. Paste your code snippet into the “Source code” input field:

Pasting code into

3. Click the Highlight button.

4. Select your Type (language). In this example, I’m using SQL:

Formatting a code snippet as SQL with ToHTML

5. Select your style. For Outlook emails, I prefer navy:

Formatting the code style as Navy with ToHTML

6. Click Highlight again to apply your changes:

Applying all changes to ToHTML code snippet

7. Your formatted code can be previewed in the Preview section. Click Copy to clipboard:

Preview of highlighted code for Outlook at ToHTML

8. Paste your code snippet into a new Outlook email. Yes, Outlook will highlight what it perceives as spelling errors. Turn a blind eye:

Pasting formatted results from ToHTML into Outlook email

9. Send your email. Here’s how it looks to the recipient:

Example of formatted code in an Outlook email

10. Rejoice that the battle has been won.

4.7 3 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
Stephen Morton
Stephen Morton
3 years ago

Unless your code is company-confidential in which case you probably do not want to paste it into a random internet website.

As an alternative, you could edit it in VSCode and then paste it into Outlook Web.

6 months ago
Reply to  Stephen Morton

VS Code pastes it with a white background (even though it and e-mail are using dark mode)

3 years ago

Great useful article. Thanks

2 years ago

Or you can use Notepad++ !
Select the Text > Go To Plugins > NppExport > Copy HTML to Clipboard > Paste in Outlook

Would love your thoughts, please comment.x