Originally written for bulldo.gs — republished here with the canonical link pointing home.

I have a Google Sheet with duplicate rows and I want to remove them programmatically, either on demand or on a schedule, without destroying the rest of my data.

// removeDuplicates.gs — dedup active sheet, keep first occurrence

// Run from Extensions > Apps Script, or bind to a trigger.

function removeDuplicateRows() {