How to format code in Gmail ?

👤 Diwas Poudel    🕒 Jan 22 2022    📁 TECH

While using Gmail, you sometimes like to send short source code of Java, C#, HTML or any code, etc to your friends then you have first tried to copy the code from your IDE to Gmail directly. When you notice the code, you will find the code does not have syntax highlighting, code indentation, loss text format, do not highlight syntax error, miss-spelling, etc. This is not attractive and recipients feel bored looking at the code. So, you try to bold, italic certain parts of the code to make it look better but it is a tedious task. Then you will search on the internet and you may get articles like this. 

Actually, this is not a professional way of sending codes but if codes few lines of code then sending code via Gmail is Okay.

In this article, I will guide you on how to format code in Gmail easily. There are various ways of achieving them, let's explain them one by one.

Method 1: Using Website 

You can format your code with the help of some website like and then paste the formatted code in Gmail.


1 Open

2 Paste your code under HTML Code: text box.

3 Select Style for the Code

4 Select the programming language of the code.

5 Click on the Highlight button.


6  Click on the "Copy to Clipboard" button.


7  Open Gmail and Paste it.


8 Click on the Send button to send.

Also read: How to use AND, OR, NOT condition in Gmail filters?

Method 2: Using Browser Extension

There are many browser extensions like MarkDown Here, CodeHighlight, Syntaxtic helps in formatting code in Gmail. 

Method 3: Using Application

Some applications like VS Code can help you to format code in Gmail.

Visual Studio Code:

Visual Studio Code is a code editor available for Windows, macOS, Linux and used by the programmer, especially for frontend development. If you are using visual studio code then you can simply copy the code from visual studio code and paste it in Gmail, then it will automatically highlight the code.

Also read: What is Gmail sync? How to fix the Gmail sync error?


Note: In the programming world, we send code to our colleagues by giving git access to the git repository and if this is not possible then we zip code and send it.


How to paste raw HTML into an email in Gmail?

Ans: You can follow above mention ways for highlighting raw HTML in Gmail. For HTML we also have another way. For this just open a text editor paste HTML code and save it with .html extension and open that file in a web browser. Then just copy the contents of that page and it will automatically copy that content as text/Html and go to the email body and paste it. You will get formatted code in Gmail


Ourtechroom Main Logo
Hello and thank you for visiting! We'll talk about everything from how to troubleshoot tech issues, to emerging technology, games, gadgets, and fun facts about technology.
Contact :