Google Apps Script to reset all fonts to normal within Workspace Docs

You can create a Google Apps Script to reset all normal text (including list items) to the default font size in a Google Docs document. Here’s a script that does that:

function resetDefaultFontSize() {
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  
  // Define the default font size (you can change this to your desired size)
  var defaultFontSize = 12; // Change to your desired font size
  
  // Iterate through all the paragraphs in the document
  var paragraphs = body.getParagraphs();
  for (var i = 0; i < paragraphs.length; i++) {
    var paragraph = paragraphs[i];
    var attributes = paragraph.getAttributes();
    
    // Check if the paragraph is not a header or a title
    if (!attributes[DocumentApp.Attribute.HEADING] && !paragraph.isListItem()) {
      paragraph.setFontSize(defaultFontSize);
    }
  }
  
  // Iterate through all the list items in the document
  var lists = body.getListItems();
  for (var i = 0; i < lists.length; i++) {
    var listItemText = lists[i].editAsText();
    listItemText.setFontSize(defaultFontSize);
  }
}

Here’s how to use this script:

  1. Open your Google Docs document.
  2. Click on “Extensions” in the top menu and then select “Apps Script.”
  3. Replace any code in the script editor with the provided code.
  4. Save the project.
  5. Click the Play button (▶️) to run the resetDefaultFontSize function.

This script will set the font size of all normal text (excluding headers and titles) and list items to the specified default font size. You can change the defaultFontSize variable to your desired font size. Remember to save and run the script whenever you want to reset the font size in your Google Docs document.