Remove indentation in paragraphs in a Google Doc using Apps Script

To remove indentation in paragraphs in a Google Doc using Apps Script, you can modify the paragraph attributes. Here’s a script to remove indentation from all paragraphs in the document:

function removeIndentationFromParagraphs() {
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var paragraphs = body.getParagraphs();
  
  for (var i = 0; i < paragraphs.length; i++) {
    var paragraph = paragraphs[i];
    paragraph.setIndentFirstLine(0);
    paragraph.setIndentStart(0);
  }
}

This script iterates through all paragraphs in the document and sets both the first line and start indentation to 0, effectively removing any indentation from the paragraphs.

To use this script:

  1. Open your Google Document.
  2. Click on “Extensions” > “Apps Script.”
  3. Delete any code in the script editor and replace it with the provided script.
  4. Save the script.
  5. Run the function removeIndentationFromParagraphs from the script editor.

This will remove the indentation from all paragraphs in your document.