Apps script that removes indents at the start of a paragraph in docs

To create a Google Apps Script that removes indents at the start of each paragraph in a Google Document, follow these instructions:

  1. Open your Google Document.
  2. Go to Extensions > Apps Script.
  3. Delete any existing code in the script editor and copy-paste the following script:
function removeParagraphIndents() {
  var document = DocumentApp.getActiveDocument();
  var body = document.getBody();
  // Get all paragraphs in the document
  var paragraphs = body.getParagraphs();
  // Iterate through all paragraphs to remove indents
  for (var i = 0; i < paragraphs.length; i++) {
    var paragraph = paragraphs[i];
    // Set the first line indent and start indent to 0
  1. Save your project with a meaningful name, for example, “Remove Paragraph Indents”.
  2. Close the script editor.
  3. Reload your Google Document for the changes to take effect.
  4. To run the script, go back to Extensions > Apps Script, select the removeParagraphIndents function from the dropdown, and click the play (▶) button.

After you run this script, it will iterate through all the paragraphs in your document and remove any indents at the beginning of them. This is particularly useful for ensuring consistency across your document or preparing it for a format that does not require paragraph indents.

Remember, the first time you run the script, you will need to authorize it. Follow the on-screen instructions to grant the necessary permissions. If you need to apply the script to new paragraphs later, you will need to run the script again.