How to format code in Gmail ?


πŸ‘€Β Diwas Poudel Β Β  πŸ•’ 31 May 2023 Β Β  πŸ“ 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 of text format, do not highlight syntax errors, miss-spelling, etc. This is not attractive and recipients feel bored looking at the code. So, you try to bold, and 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.

Benefits of Formatting Code in GmailΒ 

Here are some benefits of formatting code in Gmail:

  1. Easy to read and understand.
  2. Easy to share and improve the readability of code.

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 a 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.

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, and Syntaxtic that helps in formatting code in Gmail.Β 

Method 3: Using the 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, and 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?

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

You can also try other third-party tools like GitHub Gist, bitbucket, Pastebin,codepen, etc

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