Yes, you can remove borders from images in Google Sheets using a script, provided the images are placed "in-cell." Because images inserted into cells are treated as cell content, you use a script to remove the borders of the cells containing those images. However, images inserted "over cells" (floating images) cannot have their borders modified via Google Apps Script as the current API does not provide a method to edit the styling or border properties of OverGridImage objects.

What You'll Need

  • A Google account with access to Google Sheets.
  • A spreadsheet containing images inserted using the =IMAGE("url") function or via Insert > Image > Insert image in cell.
  • A desktop web browser (Google Apps Script editor is not available on mobile apps).

Step-by-Step

  1. Open the Google Sheet containing the images you wish to modify.
  2. Navigate to the top menu and select Extensions > Apps Script. This will open a new tab with the script editor. Note that menu labels may differ slightly depending on your account region or version.
  3. In the script editor, you will see a default function called myFunction(). Delete all existing code in the editor window to start with a clean slate.
  4. Copy and paste the following code into the editor:
    function removeImageBorders() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
      var range = sheet.getActiveRange();
      
      if (!range) {
        SpreadsheetApp.getUi().alert('Please select the cells containing the images first.');
        return;
      }
      
      // setBorder(top, left, bottom, right, vertical, horizontal)
      range.setBorder(false, false, false, false, false, false);
    }
  5. Click the Save icon (floppy disk) in the toolbar and give your project a name, such as "ImageBorderRemover."
  6. Return to your Google Sheet tab. Use your mouse to highlight the range of cells that contain the images you want to strip of borders.
  7. Go back to the Apps Script tab and click the Run button (triangle icon) located at the top of the editor.
  8. Because this is the first time running the script, Google will prompt you for authorization. Click Review Permissions.
  9. Select your Google account. You will likely see a screen stating "Google hasn't verified this app" because you just wrote it. Click Advanced and then click Go to ImageBorderRemover (unsafe) at the bottom.
  10. Click Allow to grant the script permission to modify your spreadsheet.
  11. Once the execution log shows "Execution completed," return to your sheet. The borders around the selected cells containing your images will now be gone.

Common Mistakes

One of the most frequent errors is attempting to use this script on floating images. If you used Insert > Image > Insert image over cells, the image exists on a layer above the grid. These images do not have cell borders; any outline they have is part of the image file itself or a platform-level rendering that Google Apps Script cannot access. If the script runs but nothing happens, check if your images are floating or in-cell.

Another common mistake is forgetting to select the cells before clicking Run. The script uses getActiveRange(), which means it only acts upon the area currently highlighted by your cursor. If no cells are selected, the script will trigger the alert message provided in the code and stop execution.

Users also often forget to authorize the script. If the script fails to run or gives an "Authorization Required" error, you must complete the full OAuth flow, including the "Advanced" step, as the script is considered an unverified third-party application since it was created manually.

Tips

To avoid switching back and forth between the script editor and your sheet, you can add a custom menu button to your spreadsheet. This allows you to run the border removal tool with a single click from the main toolbar. To do this, add the following code below your existing function in the Apps Script editor:

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Custom Tools')
      .addItem('Remove Image Borders', 'removeImageBorders')
      .addToUi();
}

After saving this and refreshing your spreadsheet page, a new menu item called "Custom Tools" will appear next to "Help." You can now select your images and run the script directly from the sheet.

If you want to remove borders from a specific, permanent range (for example, always cells A2 through C20) without having to select them manually, replace var range = sheet.getActiveRange(); with var range = sheet.getRange("A2:C20");. This makes the script faster for repetitive weekly reports.

For a more polished look, you can modify the setBorder parameters. The method accepts six boolean values: setBorder(top, left, bottom, right, vertical, horizontal). If you want to keep the outer border but remove the internal grid lines between images, set the outer four to true and the inner two to false.

Troubleshooting

If the borders are still visible after running the script, check for Conditional Formatting. If a rule is set to apply a border to cells based on their content, the script's setBorder(false...) command will be overridden by the conditional formatting rule. To fix this, go to Format > Conditional formatting and remove any rules affecting that range.

If you receive a "Script function not found" error, ensure that the function name in your onOpen menu (if you added one) exactly matches the function name of the main code (e.g., removeImageBorders). JavaScript is case-sensitive, so RemoveImageBorders and removeImageBorders are treated as different functions.

If the script execution hangs or times out, it is usually due to a massive selection range (thousands of cells). Try selecting smaller chunks of images at a time or ensure your internet connection is stable, as Apps Script runs on Google's servers, not your local machine.

In cases where the script runs but the image still appears to have a "border," zoom in on the image. If the border is actually a 1-pixel line inside the image file itself (a hard-coded border in the JPG or PNG), no Google Sheets script can remove it. You would need to edit the original image in a photo editor to remove the edge.

Frequently Asked Questions

Can I use this script to remove borders from images in Google Docs?

No. Google Docs uses a completely different API and object model. While you can manipulate images in Docs, the setBorder method used here is specific to the Range class in Google Sheets.

Will this script delete my images?

No. The script only modifies the formatting of the cell boundaries. It does not touch the cell value, the =IMAGE formula, or the image object itself.

Can I change the border color instead of removing it?

Yes. You can use the setBorder method in combination with setBorderColor. For example, range.setBorderColor("#FFFFFF") would make the borders white, effectively hiding them against a white background.

Does this work on the Google Sheets mobile app?

No. Custom scripts and the Apps Script editor are only supported on desktop browsers. While a script triggered by a custom menu or a trigger might execute in the background, you cannot write, edit, or manually trigger scripts from the mobile app.

Can I automate this so borders are removed as soon as I insert an image?

You can try using an onEdit(e) trigger, but be aware that the =IMAGE function or the "Insert Image" menu action does not always trigger an "edit" event. The most reliable way is to use the custom menu button described in the Tips section.