Deleting groups in Google Contacts

March 31, 2014 – 12:23 am

Over the years my contacts in Google Contacts got garbled with junk from some applications that added hundreds of contact groups. While it doesn’t really have a big impact on accessing the contacts on my phone it still bugged the neat freak in me and I wanted to eventually ™ get it fixed. Today was the day, finally…

Here is what I did

Preparations

Log into your Google account

  • Go to drive.google.com
  • In “Create” click “Connect more apps”
  • Search for “scripts” and add “Google App Script”
  • Click “Create” and select “Script”
  • Select “Create blank project”
  • Delete “myFunction” and add the code below
The actual code
function cleanupContacts{
  var groups = ContactsApp.getContactGroups();

  Logger.log("total: " + groups.length);
  for (var i = 0; i < groups.length; i++) {
    if (!groups[i].isSystemGroup()){
      groups[i].deleteGroup()
      Logger.log("deleting: " + groups[i].getName() );
    }
  }
}
Running it
  • In the Toolbar, set “Select Function” to “cleanupContacts”
  • Hit the “Run” or “Debug” button in the toolbar
Too involved?

If you don’t want to deal with all the Google App Script code, then you can try – at your OWN risk – the web app I have created around this script.

Again, it will delete ALL groups, so be careful. I also recommend to export your contacts before using the script. You can do that by selecting¬†all contacts in Google Contacts and use the “Export” function from the “More” menu.

Finally, you are executing a script that executes code from an “unknown” source (that’d be me;) while being logged in with your Google user credentials. The code is available here¬†but there is (technically) no guarantee that the code shown is the executed one, so think twice and have a backup!

Find the web app here.

  • Google User

    This was a life saver. Thank you a million times over!

  • John Podkomorski

    I’m not familiar with the source language. What would it take to make the deletion conditional on the value of “group”? For example, I’d like to delete all entries where the groupname=”DOGGROUP”?