How to Add Code Block in Google Docs & Google Slides

Code blocks are nested pieces of text that you can insert into your Google Docs by navigating to Insert > Building blocks > Code block > Language.

This feature, however, is only available to Google Workspace Business Standard, Business Plus, Enterprise Standard, Enterprise Plus, Education Standard, Education Plus, and Nonprofit subscribers.

This means that if you do not have a subscription to one of the plans mentioned above, you will be unable to write code directly in your documents, which might be a limitation if you need to work with code frequently.

Fortunately, there is another way to add code blocks in Google Docs: with the help of a free Google Docs add-on.

This tutorial will teach you how to add a code block in Google Docs.

Code Block in Google Docs

To insert a code block in Google Docs, install the “Code Blocks” add-on, add the code to your document, and select it. Then, go to Extensions > Code Blocks > Start and click “Format”.

Step 1: Go to Extensions > Add-on > Get add-ons

Code Block in Google Docs

The first step is to launch Google Docs and open the document.

Now, from the main menu, pick “Extensions,” then “Add-ons” and finally “Get add-ons” from the drop-down menu.

Step 2: Search for the “Code Blocks” add-on

Code Block in Google Docs

Enter “Code Blocks” into the search field and hit “Enter” to start the search.

Step 3: Install the add-on

Code Block in Google Docs

Now, choose the Code Blocks add-on by Alex Forsythe from the search results.

Click the “Install” button to begin installing the add-on.

Step 4: Write the code

Code Block in Google Docs

Write the code in your document after installing the add-on.

You can skip this step if you already have your code typed.

Step 5: Select the code

Code Block in Google Docs

Now, with your mouse, select the code.

Make sure that the complete code is selected.

Step 6: Go to Extensions > Code Blocks > Start

Code Block in Google Docs

It is now time to enable the “Code Blocks” add-on.

To do so, go to the top menu and select “Extensions” then “Code Blocks” and finally, “Start” to enable the add-on.

Step 7: Select a code block theme and click on “Preview”

Code Block in Google Docs

The “Code Blocks” pane will now appear on the right-hand side of the page.

The code language is set to “Auto,” which we will leave as is because the extension is smart enough to identify the language.

You can also pick the code language from the drop-down box by clicking on the “Language” option.

Choose a code block theme from the “Theme” drop-down menu. There are several themes available, so feel free to explore them all.

After you’ve chosen a theme, click the “Preview” button to get a preview of the code block.

Step 8: Click on the “Format” button

Code Block in Google Docs

If you like the theme, press the “Format” button to enter the code block into your document.

Google Slides Code Block

To insert a code block in Google Slides, install the “Code Blocks” add-on in Google Docs. Then, select your code, go to Extensions > Code Blocks > Start, and click “Format.” Copy the formatted code block and paste it into your slide.

Google Slides Code Block

Here’s how to insert a code block in Google Slides:

  1. Install the Code Blocks add-on in Google Docs.
  2. Insert your code in a Google Docs document.
  3. Select the code with your mouse.
  4. Go to Extensions > Code Blocks > Start.
  5. Select the preferred code block theme.
  6. Click Preview to see how the code will look.
  7. Click Format if you are satisfied with the theme.
  8. Copy the code block.
  9. Go to Google Slides.
  10. Press Ctrl+V to paste the copied code block.

Author: Shubham Calmblay

Shubham Calmblay, founder of appsthatdeliver.com, has a decade of experience with various Google products. He has authored 1,000+ guides for ATD, published on prestigious tech blogs. His work has garnered recognition from Protocol.com, Leadsbridge.com, MadMobile.com, and numerous other leading publications and corporations.