AI Tools

How to Find Broken Links Free With a Google Sheets Script

By Cayayti ·

Disclosure: This post has affiliate links. Clark Opal may earn a small commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases. Read our disclosure.

A Google Sheets script to check broken links sounds like something only coders use. It isn’t. I set one up on a Sunday evening with zero coding background, and it checked 33 links on my blog in under a minute.

But the reason I built it starts with Meher.

Meher writes a travel blog. Hill stations, budget trains, the best momos near every bus stand. She’s been at it for three years, and she has more than 120 posts.

Last month she messaged me a screenshot. A reader had commented on her Spiti Valley post:

“Half the booking links here are dead. Is this blog even alive?”

Ouch.

Meher’s next message was just one line. “How do I find every broken link without clicking 2,000 links one by one?”

I didn’t have an answer that night. A week later I did, and it cost nothing. Here’s what happened, step by step, with my real screenshots.

How to find broken links free with a Google Sheets script: blogger at a laptop with green, yellow and red rows

What is a Google Sheets script to check broken links?

It’s a small piece of code that lives inside a normal Google Sheet.

You give it a list of links. It visits each one in the background and writes down what the website answered. Then it paints the row green, orange, yellow or red, so you can see the problems in two seconds.

The code runs on Google’s computers, not yours. So your laptop doesn’t slow down, and you don’t install anything.

The tool behind it is called Google Apps Script. It’s free with any Google account, the same one you use for Gmail and Blogger.

Here’s what my version does:

  • It adds a new menu called Link Checker to your sheet.
  • Option 1 reads a blog post and pulls every clickable link into the sheet.
  • Option 2 checks all those links and colours the results.
  • It skips affiliate links on purpose. I’ll explain why later, because it matters for AdSense.

That’s it. No plugin, no monthly fee, no browser extension asking to “read and change all your data on all websites.”

Why do broken links hurt a small blog so much?

Think about Meher’s reader for a second.

He clicked a link, landed on an error page, came back, clicked another one, same thing. He didn’t think “the other website changed its address.” He thought Meher’s blog was dead.

That’s the real damage. Trust drops before anything else does.

Google also notices. When a page answers with an error code like 404, Google treats it as a page that doesn’t exist. Its own guide on how HTTP status codes affect Google Search explains this in plain words. A few dead outbound links won’t sink your rankings, but a blog full of them looks abandoned to readers and to reviewers.

And if you’re applying for AdSense, there’s one more reason. The AdSense program policies say a site should be easy for visitors to find their way around. Menu links that lead to missing pages are exactly what you don’t want a reviewer to find. I learned how picky that review can be when I wrote about my AdSense rejection for low value content.

I had my own small scare too. On my other blog, I once linked a government PDF that showed up fine in search results. It was a 404 when a reader opened it. I only found out because I opened it myself weeks later. Not my proudest moment.

Google Apps Script for beginners, step by step

If you’ve never opened Apps Script, don’t worry. This is Google Apps Script for beginners in the truest sense: you won’t write code. You’ll copy it, the way you copy a recipe.

Here’s the whole setup, exactly as I did it.

Step 1: Make a new Google Sheet

Open Google Sheets and start a blank sheet. I named mine “Clark Opal Link Checker”, but any name works.

Step 2: Open Apps Script

In the top menu, click Extensions, then Apps Script. A new tab opens with a code editor. It looks scary. It isn’t.

Step 3: Paste the code into a Script file

Delete the few lines already there and paste the code below.

Here’s a mistake I made, so you don’t have to. My first time, I clicked the plus button next to Files and picked HTML instead of Script. My code went into a file called Untitled.html, and nothing worked. The menu never showed up.

The fix is simple: the file name must end in .gs. When the code turns colourful, blue words and green words, you know Apps Script is reading it as real code.

Google Sheets script to check broken links pasted into a LinkChecker.gs file in Apps Script

Here’s the full Google Sheets script to check broken links. Copy all of it:

// Clark Opal broken link checker for Google Sheets
// Column A = links, B = status code, C = result, D = checked on

// Links we never test automatically (affiliate links: a test = a fake click)
var SKIP = ['amzn.to', 'tag=', 'bitli', 'earnkaro', 'cuelinks', 'linksredirect', 'bit.ly', 'dyncss'];

// Not real article links (share buttons, Blogger system pages): never imported
var IGNORE = ['sharer', 'api.whatsapp.com', 'pinterest.com/pin/create', 'intent/tweet',
  'comment/frame', 'blogger.com/profile', 'report-abuse', 'dyncss'];

function onOpen() {
  SpreadsheetApp.getUi().createMenu('Link Checker')
    .addItem('1. Import links from a page', 'importLinks')
    .addItem('2. Check all links', 'checkLinks')
    .addToUi();
}

function importLinks() {
  var ui = SpreadsheetApp.getUi();
  var ask = ui.prompt('Paste the full address of your blog post');
  if (ask.getSelectedButton() != ui.Button.OK) return;
  var page = ask.getResponseText().trim();
  var html = UrlFetchApp.fetch(page, {muteHttpExceptions: true}).getContentText();
  var found = html.match(/<a\s[^>]*href=["'](https?:\/\/[^"'#]+)["']/g) || [];
  var links = [];
  found.forEach(function (h) {
    var url = h.replace(/^.*href=["']/, '').replace(/["']$/, '').replace(/&amp;/g, '&');
    var junk = IGNORE.some(function (s) { return url.indexOf(s) != -1; });
    if (!junk && links.indexOf(url) == -1) links.push(url);
  });
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.clear();
  sheet.getRange(1, 1, 1, 4).setValues([['Link', 'Status', 'Result', 'Checked on']]).setFontWeight('bold');
  if (links.length) sheet.getRange(2, 1, links.length, 1).setValues(links.map(function (l) { return [l]; }));
  ui.alert(links.length + ' links found. Delete the ones you don\'t need, then click 2. Check all links.');
}

function checkLinks() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var last = sheet.getLastRow();
  if (last < 2) return;
  var urls = sheet.getRange(2, 1, last - 1, 1).getValues().map(function (r) { return String(r[0]).trim(); });
  var out = [], colours = [];
  for (var i = 0; i < urls.length; i += 20) {
    var batch = urls.slice(i, i + 20);
    var res = fetchBatch(batch);
    for (var j = 0; j < batch.length; j++) {
      var row = describe(batch[j], res[j]);
      out.push([row[0], row[1], new Date()]);
      colours.push([row[2], row[2], row[2], row[2]]);
    }
  }
  sheet.getRange(2, 2, out.length, 3).setValues(out);
  sheet.getRange(2, 1, colours.length, 4).setBackgrounds(colours);
}

function fetchBatch(batch) {
  var reqs = [], where = [], res = [];
  batch.forEach(function (url, k) {
    res[k] = null;
    if (/^https?:\/\//.test(url) && !isSkipped(url)) {
      reqs.push({url: url, muteHttpExceptions: true, followRedirects: false});
      where.push(k);
    }
  });
  if (!reqs.length) return res;
  try {
    UrlFetchApp.fetchAll(reqs).forEach(function (r, n) { res[where[n]] = r; });
  } catch (e) {
    // one dead address breaks the whole batch, so try them one by one
    reqs.forEach(function (req, n) {
      try { res[where[n]] = UrlFetchApp.fetch(req.url, req); }
      catch (err) { res[where[n]] = 'ERROR'; }
    });
  }
  return res;
}

function isSkipped(url) {
  return SKIP.some(function (s) { return url.indexOf(s) != -1; });
}

function describe(url, r) {
  if (!url) return ['', '', '#ffffff'];
  if (!/^https?:\/\//.test(url)) return ['', 'Not a web link', '#eeeeee'];
  if (isSkipped(url)) return ['', 'Skipped: affiliate link, open it yourself', '#eeeeee'];
  if (r == 'ERROR') return ['', 'Broken: site not found', '#f4c7c3'];
  var code = r.getResponseCode();
  if (code < 300) return [code, 'OK', '#d9ead3'];
  if (code < 400) return [code, 'Redirects to ' + (r.getHeaders()['Location'] || '?'), '#fce5cd'];
  if (code == 403 || code == 429) return [code, 'Blocked the checker: open it yourself', '#fff2cc'];
  return [code, 'Broken', '#f4c7c3'];
}

Step 4: Save it

Press Ctrl + S. The words “Unsaved changes” at the top disappear, and the little orange dot next to your file name goes away. The box next to the Debug button should now say onOpen.

Step 5: Reload your sheet

Go back to your sheet’s tab and reload the page. On my laptop, F5 didn’t work because that key controls screen brightness. If that happens to you, click the round reload arrow at the top of Chrome or press Ctrl + R.

Wait five seconds. A small “Running script” message pops up and vanishes. Then a new menu called Link Checker appears, right after Help.

Link Checker menu added to Google Sheets by the broken links script

That’s the whole setup. Took me about ten minutes, including the HTML mistake.

What does “Google hasn’t verified this app” mean?

The first time you click the new menu, Google shows a red warning that says “Google hasn’t verified this app.” My heart skipped a beat the first time I saw it.

Then I looked closer. The developer email on that screen was my own email.

Google shows this warning for any script that hasn’t gone through its review process. Your own little script will never go through that, so you’ll always see it. That’s normal.

Google hasn't verified this app warning for my own Apps Script, Advanced link marked

To continue, click Advanced (small text at the bottom left), then “Go to Clark Opal Link Checker (unsafe).” The word unsafe only means Google hasn’t checked it. You wrote it, or rather, you pasted it and can read it.

Next, Google asks what the script may do. There are two boxes:

  • See, edit, create and delete your Google Sheets spreadsheets. The script needs this to write results into your sheet. Google words it broadly, but this code only touches the sheet you have open.
  • Connect to an external service. This is how it visits each link.

Tick Select all, then click Continue. If you leave a box empty, the script stops with an error.

Apps Script permission screen with Select all ticked for Google Sheets and external service

One honest warning, though. Only do this for code you understand or code from someone you trust. If a stranger’s spreadsheet ever shows you this screen, click Back to safety. Google’s help page on managing third-party access to your account also shows how to remove a script’s access later, if you ever change your mind.

How to find broken links on a Blogger blog with this script

Now the fun part.

Click Link Checker, then “1. Import links from a page.” A box asks for the full address of your blog post. I pasted my guide on connecting a Cloudflare domain to Blogger, because it has lots of official links in it.

Import links box of the Google Sheets script to check broken links on a Blogger post

A few seconds later, a message said: 51 links found.

Wait. 51? My post doesn’t have 51 links.

So I looked at the list before checking anything. Good thing I did.

The surprise in row 12

My first version of the script grabbed every web address in the page’s code. Not just the links readers click, but also hidden theme files: the favicon, the RSS feeds, Google Fonts.

And row 12 had a file from blogger.com with “authorization.css” in its name.

Blogger view counter file found in row 12 of the imported links list

That little file is part of how Blogger counts views. If my script had checked it, it could have added fake views to my own post. That’s the kind of thing I never want on a blog that’s applying for AdSense, since Google is strict about any traffic that isn’t from real people.

So I changed the script. Now it only collects real clickable links, and it never touches that counter file. The version in this post already has the fix.

The second clean-up

The next run found 40 links. Better, but there was still some noise:

  • Facebook, WhatsApp, Pinterest and Twitter share buttons
  • Blogger’s comment box
  • Blogger’s “report abuse” link
  • My Blogger profile link

None of these are links you write in a post. And the profile one was sneaky, because Blogger profiles can show a view count too. A script visiting it again and again would add views that aren’t real.

So the script now ignores all of these by itself. Third run: 33 links found. Perfect.

33 links found message after the script ignored share buttons and Blogger system links

Those 33 included my menu, sidebar and footer links. I left them in on purpose. A broken menu link is worse than a broken link deep inside a post, because it shows up on every single page.

If you have a big blog like Meher’s, do one post at a time. Start with your most visited posts. Blogger Stats, under Posts, shows you which ones those are.

How to check URL status code in Google Sheets (and read the colours)

Now click Link Checker, then “2. Check all links.”

The script checks 20 links at a time, all together, which is why it’s fast. For my 33 links it took less than half a minute.

Every link gets a status code. That’s a three-digit number the website sends back, like a reply to “Are you there?” Mozilla keeps a clear list of every HTTP status code if you’re curious, but you only need a few:

Colour Status code What it means What you do
Green 200 The page is there Nothing
Orange 301, 302 The link sends people somewhere else Check where it goes
Yellow 403, 429 The site blocked the checker Open it yourself in Chrome
Red 404, 410, 500 Missing or broken page Fix or remove the link
Red, no code none The website doesn’t exist anymore Remove the link
Grey none Skipped, like affiliate links Open it yourself

My result? 31 green rows, one yellow, one orange. Zero red.

Google Sheets script to check broken links results: 31 links OK with status 200 and one 403

I’ll be honest, I was a little proud. But the yellow and orange rows taught me more than the green ones.

Why does a link show 403 when it opens fine in Chrome?

Row 15 was a page from Cloudflare’s learning centre. Status 403. The script wrote: “Blocked the checker: open it yourself.”

But I’d opened that exact page in Chrome a week earlier, and it worked fine.

Here’s what’s going on. 403 means “forbidden.” Some big websites use bot protection. When a request comes from a server instead of a person’s browser, they refuse it. Mozilla’s page on the 403 Forbidden status explains the idea in more detail.

Your Google Sheets script runs on Google’s servers, so to that website it looks like a robot. Which, to be fair, it is.

So a 403 doesn’t mean the link is broken. It means “I can’t tell you, check it yourself.” That’s why the script paints those rows yellow and not red.

My friend Farhan runs a small coaching website. When I showed him his results, he panicked over five yellow rows. All five opened perfectly in his browser. Now he just opens the yellow ones by hand and moves on.

What is a 302 redirect in a link checker?

Row 28 was simply www.blogger.com. Status 302, painted orange.

The result said it redirects to a Google sign-in page. That makes sense. Blogger’s home page sends you to log in first.

302 redirect status code in Google Sheets for blogger.com going to a login page

A redirect means the website says “not here, go there instead.” There are two common kinds:

  • 301 means the page has moved for good. You should update your link to the new address.
  • 302 means a temporary move, like a login page or a country page. A 302 redirect is usually fine to leave as it is.

Google has a helpful guide on redirects and Google Search if you want the full story.

My script doesn’t follow redirects. It tells you where the link goes and lets you decide. I like that, because sometimes a redirect quietly sends readers to a home page instead of the article you linked. That’s not technically broken, but it’s still useless for your reader.

When I set up my own domain, I saw this up close. The plain clarkopal.org address redirects to the www version. That one is on purpose and totally fine. I wrote about it in my post on removing ?m=1 from Blogger mobile URLs, which is another redirect story.

Is it safe to check affiliate links automatically?

Short answer: no. That’s why my script skips them.

When a script visits an affiliate link, the shop can’t tell it apart from a real visit. It may count as a click. It might even drop a tracking cookie with nobody there to buy anything.

Affiliate programs hate that. So does Google. That’s the main reason I’ll never check affiliate links automatically, on any of my blogs. Fake clicks and hidden cookie tricks are on Google’s list of invalid traffic, and an AdSense account is shared across all your sites. I’m not risking that for a colour in a spreadsheet.

So any link with words like amzn.to, tag=, bitli, earnkaro, cuelinks or linksredirect gets a grey row that says “Skipped: affiliate link, open it yourself.” You check those few by hand, once in a while, like a normal reader would.

If your network uses a different short link, add a piece of it to the SKIP list at the top of the code. Keep the quotes and the comma, like this: ‘yourshortlink’.

While you’re at it, make sure affiliate links in your posts carry rel=”sponsored”. Google explains why in its guide to qualifying your outbound links.

How does this compare with other ways to check links?

Meher asked me this too. Fair question. Here’s how I see it after trying the script for real:

Method Cost Speed Good for Watch out for
Clicking every link yourself Free Very slow A few affiliate links You’ll give up by post 10
Google Sheets script Free About 30 seconds per post Official and internal links 403 rows need a manual check
Chrome extensions Often free Fast One page at a time Wide permissions, may visit affiliate links
Paid SEO tools Monthly fee Whole site Big blogs with hundreds of posts Costly for a new blog

I haven’t paid for an SEO tool, so I can only speak for the free options. Same as in my list of free keyword research tools for new bloggers, I’d rather start free and pay only when the blog earns enough.

How many links can a Google Sheets script to check broken links handle?

More than you’ll need.

Google sets daily limits on how many web requests a free account’s scripts can make. You can see the current numbers on the Apps Script quotas page. For a normal blogger who wants to check URL status codes in Google Sheets for a few posts a week, you won’t come close.

There’s also a time limit on how long one run can take. So don’t paste 3,000 links at once. One post, or a handful of posts, per run is the sweet spot.

My cousin Ishaan tried to be clever and pasted links from 40 posts in one go. The script stopped halfway. He split it into four smaller runs and it worked fine.

If you want to learn how the “fetch” part works in detail, Google documents it on the UrlFetchApp reference page.

Want to go deeper into Sheets itself? A beginner-friendly Google Sheets book can save you hours of random videos.

Can AI help you change the script?

Yes, and this is where it gets fun.

You don’t need to learn JavaScript to make small changes. You can paste the code into an AI chat and ask in plain words. I tried this myself when I wanted to understand what each part did.

Here’s a prompt you can copy:

I’m a blogger with no coding experience. Below is a Google Apps Script that checks broken links in Google Sheets. Explain in simple words what each function does. Then change it so it also writes the date of the last 404 error in column E. Keep the SKIP list for affiliate links exactly as it is. Show me the full new code so I can replace the old one. [paste the code here]

Two rules I follow with AI and code. First, never paste passwords, API keys or private data into the chat. This script has none, which is one reason I like it. Second, test any changed code on a copy of your sheet first. AI makes confident mistakes.

And if AI’s answer makes you curious about code, a simple JavaScript book for beginners covers the same language Apps Script uses. There are also a few books on Google Apps Script itself if you want to automate more of your blog work.

What mistakes should you avoid with a Google Sheets script to check broken links?

I made some of these. Others, my friends made. Learn from all of us.

  • Pasting the code into an HTML file. The file must end in .gs. If the code isn’t colourful, it isn’t running.
  • Forgetting to save. If “Unsaved changes” is still at the top, your sheet runs the old code.
  • Checking before looking. Always look at the imported list first. That’s how I caught Blogger’s view counter in row 12.
  • Removing the affiliate skip list. Don’t. A fake click isn’t worth the risk.
  • Treating yellow as broken. A 403 usually means a bot block. Open it yourself before deleting anything.
  • Deleting links in a panic. For a red link, first search for the page’s new address. Often it just moved.
  • Running it every day. Once a month is plenty for most blogs. Your posts don’t change that fast.

One more small thing. Keep the sheet private. There’s no reason to share it, and it lists every link on your blog in one place.

I keep a simple routine now. On the first Sunday of each month, I run the checker on my five newest posts and my top three. I note any red rows in a small planner notebook on my desk, fix them in Blogger, and run the check again. It takes about 20 minutes, chai included.

So, did Meher fix her travel blog?

She did. Mostly.

I sent her the same sheet. She ran the Google Sheets script to check broken links on her ten most visited posts first.

Her Spiti Valley post had 14 red rows. Old homestay websites that had shut down. A bus booking page that moved. Two government tourism pages with new addresses.

She fixed the moved ones, removed the dead ones and added a short “last checked” line at the bottom of the post. Then she replied to that angry comment:

“You were right. All links checked and fixed today. Thanks for telling me.”

The same reader wrote back. “Great post now. Going in June.”

For me, it’s still the easiest free way to find broken links on a Blogger blog.

That’s the whole point. A Google Sheets script to check broken links won’t write better posts for you. But it makes sure the good posts you’ve already written don’t let a reader down.

If you’re still setting up your blog, my notes on why Blogger Stats show more views than Google Analytics might save you another headache. And every guide I’ve written is on the Clark Opal sitemap page.

Recommended reads

Disclaimer: This guide is based on my own test on 25 October 2026 with a free Google account. Google can change Apps Script screens, permissions and limits at any time, so check the official pages linked above. Use the script at your own risk, and never use it to visit affiliate links or ads.

C
Written by Cayayti

I'm Cayayti, the person behind Clark Opal. I test blogging tools, AI tools and SEO methods on my own blogs first, then write down what worked, what broke and what it cost, in plain words. I only review tools I've actually used.

Leave a comment

Your email address will not be published. Required fields are marked *