How to add syntax highlighting to code snippets in Gmail messages

I’m trying to share some programming code with my colleagues through Gmail, but the plain text format makes it really hard to read. The code just appears as regular text without any color coding or formatting that you normally see in code editors. This makes it difficult for others to understand the structure and syntax of what I’m sending.

I’ve tried copying and pasting directly from my IDE, but Gmail strips out all the formatting and colors. Is there any way to preserve syntax highlighting when sending code through Gmail? Maybe there’s a browser extension, a formatting trick, or some other method that can help make code more readable in email messages?

I know there are other ways to share code like GitHub gists or pastebin, but sometimes I just need to include a quick code snippet directly in the email body. Any suggestions would be really helpful.

code snippets in gmail? i feel ya! try using a tool like codepen to format it, then just take a ss of the code. looks way better than plain text, trust me!

I faced a similar issue when sharing code snippets through Gmail. One effective solution I’ve found is to use an online syntax highlighter like highlight.js or Prism. You can paste your code there and it generates highlighted HTML. Just make sure to paste it into Gmail using Ctrl+Shift+V to retain the formatting. Alternatively, using Gmail’s monospace formatting by selecting your code and changing it to Courier New helps maintain spacing, though it won’t add colors. These methods have made my code much easier for colleagues to read.

After months of dealing with this headache, I found Carbon (carbon.now.sh) works great. Just paste your code, pick a theme and language, then export as PNG. Looks professional and keeps perfect syntax highlighting that shows up the same way for everyone. Unlike HTML solutions that break based on someone’s email settings, images always render properly. I’ve also used the Code Screenshot extension for VS Code - select your code and it generates a clean image right from the editor. Both ways guarantee your colleagues see exactly what you meant, no matter what Gmail settings or email client they’re using.

Screenshots work but get messy when you’re sending code snippets regularly.

I used to waste tons of time formatting code for emails until I automated it.

Here’s what I built: a workflow that grabs your code, runs it through a syntax highlighter API, converts to HTML with proper colors, and formats it for Gmail. Trigger it with a hotkey or paste code into a form and get formatted HTML back.

Mine’s connected to Slack too - same workflow handles both email and chat. Takes 10 minutes to set up, saves hours weekly.

Best part? You can customize colors to match your team’s preferences. Way more professional than screenshots and actually searchable.

You can build this easily with Latenode: https://latenode.com