How to format code in Gmail ?


👤 Diwas Poudel    🕒 Oct 14 2021    📁 Fix    📜 0 comment

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 bore 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 tohtml.com and then paste the formatted code in Gmail.

Steps:

1 Open tohtml.com

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.

tohtml-code-generator

6  Click on the "Copy to Clipboard" button.

copy-to-clipboard

7  Open Gmail and Paste it.

code-format-in-gmail

8 Click on the Send button to send.

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.

visual-studio-code-to-gmail-paste-code

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.

FAQ

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 and 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