How to Add Code Block in Google Docs: Step by Step Guide

Last Updated : 9 May, 2026

When writing technical documents, tutorials, or sharing code snippets in Google Docs, it is important to present code clearly so readers can understand it easily. Although Google Docs does not have a dedicated code block feature, you can use several simple methods to format code in an organized and professional way.

Steps to Install the Code Block Extension in Google Docs

Follow these steps to install the code block extension in Google Docs:

Step 1: Go to the Google Workspace marketplace

Use this link to go to the Google Workspace Marketplace home page.

Note: Make sure to log in to your Google account if you are not already logged in.

How to Add Code Block in Google Docs
Google Workspace Marketplace

Step 2: Search Code Blocks add-on

Type Code Block add-on in the search bar and press Enter. Select any of the first add-on.

Note: Here we will be selecting the first Code Block Add on for better demonstration.

How to Add Code Block in Google Docs
Search code block add on

Step 3: Install Code Blocks

Click on the Install option to add the Code Blocks extension.

How to Add Code Block in Google Docs
Install code block

Step 4: Allow Download

Give permissions to allow download by clicking on Continue.

How to Add Code Block in Google Docs
click continue

Step 5: Select your Gmail Account

Now select the existing Gmail account.

How to Add Code Block in Google Docs
choose a Google account

Step 6: Sign In and Click Continue

Click on Continue to sign in to your account.

How to Add Code Block in Google Docs
click continue

Step 7: Click on Allow Code Blocks

Once you are signed in, you will see the list of things Code Block can do with your data. Click Allow to proceed with the download.

How to Add Code Block in Google Docs
click allow

Once installed, the Google Docs code block add-on will appear in your add-ons list, allowing you to easily insert code blocks in Google Docs whenever needed.

How to Add Code Block in Google Docs
Add-on installed

How to Use Code Blocks in Google Docs

The Google Docs code block add-on allows users to format and highlight code with ease, improving the presentation of code snippets in technical documents. Follow these steps to add code in Google Docs using the Code Block add-on:

Step 1: Open the desired Google Docs File

Open the desired document from the Google Docs home page.

How to Add Code Block in Google Docs
open the desired document

Step 2: Enter and Select the Code

You can add the code by directly typing it or by simply copying and pasting it from a code editor.

How to Add Code Block in Google Docs
select the code

Step 3: Go to the Extension Tab and Select Code Blocks

Go to the Extensions menu. You will see the added extensions in the list. Click on Code Blocks and select Start.

How to Add Code Block in Google Docs
start code blocks

Step 4: Select your preferred Language

In the side pane that opens, select the desired language from the drop-down.

How to Add Code Block in Google Docs
select language

Step 5: Select a Code Block Theme

To change the colors, you can choose a different theme from the Theme drop-down. Turn on the preview option to see how a particular theme looks.

Note that you will have to click on the Preview button every time you select a theme.

How to Add Code Block in Google Docs
select theme

Step 6: Click on Format Button

Click on Format to add the code block to your document.

How to Add Code Block in Google Docs
format button

Step 7: Preview Changes

Here is what the code block looks like:

How to Add Code Block in Google Docs
Result

Tips for Formatting Code Blocks in Google Docs

  • Use Consistent Fonts: For manually formatted code, always use a consistent mono-spaced font for better readability.
  • Apply Styles: If your code requires specific styling, such as bold or italic text, use the toolbar options to apply styles within your Google Docs code block.
  • Leverage Shortcuts: To make inserting code quicker, familiarize yourself with Google Docs shortcuts. For example, use Ctrl + Shift + 8 to quickly insert bullet points when listing code snippets.
Comment