Automate Image Alt Text Auditing & Enhancement with n8n & OpenAI

Discover how this n8n workflow automates auditing and enhancing image alt text from any webpage using OpenAI GPT-4. It helps fix poor or missing alt attributes quickly and accurately, saving hours of manual work and improving web accessibility.
manualTrigger
set
httpRequest
+6
Workflow Identifier: 2127
NODES in Use: manualTrigger, set, httpRequest, code, googleSheets, if, limit, splitInBatches, openAi
Automate image alt text with n8n and OpenAI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow finds all images on a webpage and checks their alt texts.

If alt text is missing or too short, it creates better descriptions using OpenAI GPT-4.

It saves results in Google Sheets for easy review and tracking.

This fixes accessibility and SEO issues fast without manual work.


Who should use this workflow

Anyone needing to improve image alt texts on websites.

Great for website managers who want fast audits and fixes.

Best for pages with static HTML images, less so for sites with dynamic image loading.


Tools and services used

  • n8n: to build and run the automation workflow.
  • Google Sheets API: records image data and updates alt text.
  • OpenAI GPT-4 (Langchain node): generates improved alt text descriptions.
  • HTTP Request node: downloads webpage HTML.

Inputs, Processing & Outputs

Inputs

  • A webpage URL to audit images from.
  • Google Sheets credentials and open API access.
  • OpenAI API key for GPT-4 access.

Processing steps

  • Download page HTML using HTTP Request node.
  • Extract all <img> tags with their src and alt attributes using a JavaScript Code node.
  • Convert relative URLs to full URLs using base URL data.
  • Save extracted data into Google Sheets to track all images.
  • Reload data from Google Sheets and filter images with alt text shorter than 100 characters.
  • Limit batch size to avoid too many API calls.
  • Send each short alt text image URL to OpenAI GPT-4 using the Langchain node to get better alt text under 150 characters.
  • Update Google Sheets rows with suggested new alt texts for audit review.

Outputs

  • A Google Sheet with original and AI-improved alt texts per image.
  • A clear list of images needing accessibility fixes.

Beginner step-by-step: How to use this workflow in n8n

Step 1: Import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor.
  3. Use the Import from File option to load the workflow.

Step 2: Configure credentials and settings

  1. Add Google Sheets credentials with proper access.
  2. Add OpenAI API Key to the Langchain OpenAI node.
  3. Update the Google Sheets document ID and sheet name if different.
  4. Edit the Page Link node to set the webpage URL and base URL to audit.

Step 3: Test and activate

  1. Run the workflow manually once to ensure it works and data writes correctly.
  2. Check Google Sheet for results and new alt text suggestions.
  3. Activate the workflow for production use as needed.

Consider self-host n8n for running this regularly if preferred.


Key code snippet for image extraction

This JavaScript code extracts all image tags and alt texts from the page HTML and fixes relative URLs:

const html = $input.first().json.data;
const baseUrl = $('Page Link').first().json.baseUrl;

const imgTagRegex = /<img\b[^>]*>/gi;
const altAttrRegex = /alt\s*=\s*["']([^"']*)["']/i;
const srcAttrRegex = /src\s*=\s*["']([^"']*)["']/i;

const imageTags = html.match(imgTagRegex) || [];

const results = imageTags.map((tag, index) => {
  const altMatch = tag.match(altAttrRegex);
  const srcMatch = tag.match(srcAttrRegex);

  let alt = altMatch ? altMatch[1] : '[No alt text]';
  let src = srcMatch ? srcMatch[1] : '[No src]';

  if (src !== '[No src]' && !src.startsWith('http')) {
    if (baseUrl.endsWith('/') && src.startsWith('/')) {
      src = baseUrl + src.slice(1);
    } else if (!baseUrl.endsWith('/') && !src.startsWith('/')) {
      src = baseUrl + '/' + src;
    } else {
      src = baseUrl + src;
    }
  }

  return {
    index: index + 1,
    src,
    alt,
    altLength: alt.length,
  };
});

return results.map(item => ({ json: item }));

This code helps find which images need alt text improvement.


Common issues and tips

  • No images found: The webpage might use JavaScript to load images after page load. Consider tools that run page scripts to scrape dynamic content.
  • Google Sheets update errors: Check if Google Sheets API credentials have permission to edit the specific spreadsheet.
  • OpenAI API limits: Make sure the API Key is correct and requests do not exceed quota.
  • Broken URLs: Verify the base URL matches the audited webpage domain to resolve relative paths.

Customization ideas

  • Change the minimum alt text length filter to catch more or fewer images needing updates.
  • Adjust the batch size node to control how many images process per run.
  • Switch to another GPT-4 or other OpenAI model if cost or speed is a concern.
  • Add extraction of other image attributes in the code node like titles or dimensions.
  • Store results in CSV or databases instead of Google Sheets if preferred.

Summary of results

✓ Quickly gathers images and alt text from any static (HTML) webpage.

✓ Finds alt texts that are missing or very short and generates better descriptions.

✓ Saves both original and improved alt texts in Google Sheets for easy audit.

→ Makes image accessibility and SEO fixes much faster and less error-prone.

→ Helps website managers track progress and improve user experience for all visitors.


Automate image alt text with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

This workflow works best on websites with static HTML images. Websites loading images dynamically by JavaScript may not show all images.
Yes, calling OpenAI GPT-4 uses paid API quota. Use batch limits to control costs.
Check Google Sheets API credentials and make sure they have edit permission on the target spreadsheet.
Yes, but carefully set batch limits and watch API rate limits to avoid errors.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.