Your image filenames are a direct signal Google uses to rank your images — and most websites get them completely wrong. This guide covers every rule for naming image files for SEO, with 40+ real-world examples across every industry, plus scripts to bulk-rename existing images without breaking your site.
Google's own documentation states that "the filename can give Google clues about the subject matter of the image." This isn't a minor hint — filenames are one of the explicit signals Google uses to understand and rank images in both Google Image Search and standard web search.
When Google crawls your page, it looks at several signals to understand each image: the filename, the alt attribute, the surrounding text, the page title, and structured data. The filename is the first signal in the chain — it's visible in the image URL before any page content is rendered.
Filename → Alt text → Surrounding body text → Image caption → Page title/H1 → Structured data (ImageObject). All signals reinforce each other. A great filename paired with weak alt text still underperforms versus both being well-optimized.
A filename like IMG_4872.jpg or photo-1.png tells Google absolutely nothing. You're throwing away a free, permanent optimization signal on every single image. For an e-commerce site with 5,000 product images, that's 5,000 missed ranking opportunities.
Google Image Search drives real commercial traffic — especially for product, recipe, and how-to content. A well-named image can rank independently of the parent page and bring in visitors who never would have found the page through regular search.
red-leather-sofa.jpg — not underscores, not spaces, not camelCase. Hyphens are the only word separator Google reads correctly in filenames.Red-Sofa.jpg and red-sofa.jpg are different files. Lowercase prevents 404 errors and duplicate content issues.buy-cheap-red-sofa-online-discount-sofa-sale.jpg is spam. Google ignores over-stuffed filenames and may penalize the page. 3–5 words is the limit.This is one of the most common questions in image SEO — and it has a clear, documented answer.
red-leather-sofa.jpg
Google reads this as three separate words: red, leather, sofa. All three are indexable keywords.
red_leather_sofa.jpg
Google reads this as one word: "red_leather_sofa". None of the individual terms are separately indexed.
Google's John Mueller has confirmed this multiple times: hyphens are treated as word separators in URLs; underscores are treated as word joiners. This applies to both page URLs and image filenames.
Spaces in filenames get URL-encoded to %20 — so red leather sofa.jpg becomes red%20leather%20sofa.jpg in the browser. While this technically works, it makes filenames fragile, breaks in some tools, and looks unprofessional. Always use hyphens.
| Separator | Google reads as | Recommendation |
|---|---|---|
red-sofa.jpg | "red" + "sofa" (2 words) | Use This |
red_sofa.jpg | "red_sofa" (1 word) | Avoid |
redSofa.jpg | "redSofa" (1 word) | Avoid |
red sofa.jpg | "red" + "sofa" (encoded as %20) | Avoid |
RedSofa.jpg | "RedSofa" (case-sensitive risk) | Avoid |
A well-structured image filename follows a consistent pattern: subject → descriptor → context → variant. Not every image needs all four parts — but understanding each one helps you write better filenames faster.
linen-duvet-cover-king-white.webp
Product → material → variant → size → color
sourdough-bread-sliced-overhead.webp
Subject → state → angle — all indexable terms
open-plan-kitchen-brooklyn-apartment.webp
Room type → style → location — great for local SEO
IMGVO-compress-image-dashboard.webp
Brand → feature → page type — brand + keyword
Different industries need different filename strategies. Here's how to apply the rules across the most common use cases.
Every good filename above answers: what is it, what does it look like or where is it, and what context is it in? If your filename answers all three in 3–5 words, it's a good filename.
Filenames and alt text are complementary, not redundant. They serve different purposes and are read by different systems at different times.
| Signal | Read By | When | Purpose |
|---|---|---|---|
| Filename | Google crawler, CDN logs, analytics | On crawl, before page renders | URL-level keyword signal for indexing |
| Alt text | Screen readers, Google, browser fallback | When page renders | Accessibility + contextual keyword signal |
| Caption | Sighted users, Google | When page renders | User-facing context, supports alt text |
They should describe the same image from slightly different angles — consistent but not identical. The filename is a concise slug; the alt text can be more descriptive and human-readable.
nike-air-max-270-white.webp
alt= "Nike Air Max 270 in white colorway, side view on white background"
IMG_9821.jpg
alt= "Nike Air Max 270 in white"
Filename gives zero signal — missed opportunity.
nike-air-max-270-white.webp
alt= "nike-air-max-270-white"
Alt text should be human-readable, not a slug copy.
sourdough-loaf-overhead.webp
alt= "Freshly baked sourdough loaf with scored crust, overhead shot on wooden board"
The folder path your image lives in is also part of its URL — and therefore also a signal. A well-organized image directory reinforces the filename's keyword signal.
/images/IMG_4872.jpg
No context at any level. Folder and filename are both wasted signals.
/images/sofas/red-leather-sofa-3-seater.webp
Category folder + descriptive filename = two levels of keyword context.
# E-commerce site /images/ products/ sofas/ red-leather-sofa-3-seater-front.webp red-leather-sofa-3-seater-side.webp chairs/ ergonomic-office-chair-mesh-black.webp blog/ how-to-clean-leather-sofa-steps.webp brand/ logo-horizontal-white.svg # Recipe / food blog /images/ recipes/ pasta/ spaghetti-carbonara-plated-overhead.webp desserts/ tiramisu-slice-espresso.webp how-to/ pasta-dough-rolling-technique.webp
If you use a CDN or image transformation service, ensure the canonical image URL (the one in your HTML src attribute and sitemap) reflects your semantic folder structure. CDN-specific paths like cdn.example.com/f_auto,q_80/v1/products/img001.jpg carry no keyword signal from the transformation parameters.
Renaming images that are already indexed carries some risk — Google has to re-crawl and re-index the new URLs. Done correctly, the long-term SEO gain outweighs the short-term disruption.
.htaccess (Apache) or Nginx config. This preserves any backlinks pointing to the old image URL.If you have thousands of images, rename in batches of 200–500 at a time, spaced a few weeks apart. Mass URL changes can temporarily confuse Google's understanding of your site structure and cause brief ranking drops across unrelated pages.
Manual renaming doesn't scale past a few dozen images. These scripts automate the process and output a redirect map as a side effect.
#!/bin/bash # Converts filenames to lowercase and replaces spaces/underscores with hyphens # Usage: ./rename-images.sh ./images/products DIR="${1:-.}" find "$DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.webp" \) | while read -r FILE; do DIR_PATH=$(dirname "$FILE") BASENAME=$(basename "$FILE") # Lowercase, replace spaces and underscores with hyphens NEWNAME=$(echo "$BASENAME" | tr '[:upper:]' '[:lower:]' | sed 's/[ _]/-/g') if [ "$BASENAME" != "$NEWNAME" ]; then mv "$DIR_PATH/$BASENAME" "$DIR_PATH/$NEWNAME" # Output redirect map: old → new echo "Redirect 301 /images/$BASENAME /images/$NEWNAME" >> redirects.conf fi done echo "Done. Redirects saved to redirects.conf"
import os, re, csv from pathlib import Path IMAGE_DIR = "./images" LOG_FILE = "rename-log.csv" EXTS = {".jpg", ".jpeg", ".png", ".webp", ".gif"} def seo_name(name: str) -> str: name = name.lower() name = re.sub(r'[\s_]+', '-', name) # spaces/underscores → hyphens name = re.sub(r'[^a-z0-9\-\.]', '', name) # strip special chars name = re.sub(r'-{2,}', '-', name) # collapse multiple hyphens return name with open(LOG_FILE, 'w', newline='') as log: writer = csv.writer(log) writer.writerow(["old_path", "new_path", "status"]) for p in Path(IMAGE_DIR).rglob("*"): if p.suffix.lower() not in EXTS: continue new_name = seo_name(p.stem) + p.suffix.lower() new_path = p.parent / new_name if p.name == new_name: writer.writerow([p, new_path, "unchanged"]) continue p.rename(new_path) writer.writerow([p, new_path, "renamed"]) print(f"Done. Audit log saved to {LOG_FILE}")
Before running any rename script on production, test with a dry run: replace the mv / p.rename() call with a print() statement to preview all changes without modifying any files.
IMG_4872.jpg, photo-1.png, screenshot.png, or image.jpg..webp or .avif preferred; lowercase extension always.Yes. Google explicitly states that descriptive filenames help it understand image content. A filename like red-leather-sofa-living-room.jpg gives Google context it uses for both Google Image Search ranking and as a supporting signal for the overall page topic. It's a free, permanent optimization signal — most sites ignore it entirely.
Always use hyphens. Google treats hyphens as word separators in URLs and filenames — so red-sofa is read as two words: "red" and "sofa". Underscores are treated as joiners, meaning red_sofa is read as one word: "red_sofa". This is documented behavior confirmed by Google's John Mueller multiple times.
Use 3–5 words that naturally describe the image. Include your primary keyword if the image genuinely shows what that keyword refers to. Avoid stuffing multiple keywords into one filename — red-sofa-buy-sofa-cheap-sofa-online.jpg is spam and Google ignores or penalizes it.
Renaming images can temporarily affect rankings as Google re-crawls the new URLs. To minimize disruption: set up 301 redirects from old image URLs to new ones, update all src and srcset references in your HTML, and update your image sitemap. The long-term SEO benefit of descriptive filenames outweighs the short-term crawl disruption for most sites.
They should be consistent but not identical. Both the filename and alt text should describe the same image, but they serve different purposes. The filename is a URL-level signal for crawlers; the alt text is a human-readable description for users and screen readers. A filename like nike-air-max-270-white.webp pairs well with alt text like Nike Air Max 270 in white, side view on white background.
Keep filenames under 60 characters (not counting the extension). 3–5 descriptive hyphenated words is the sweet spot. Shorter filenames are easier to maintain, less likely to be truncated in server logs and analytics tools, and still give Google enough signal to understand the image.
Both matter, and they work together. Alt text is generally considered a stronger SEO signal because it's a named HTML attribute specifically designed for image description. However, the filename is still a meaningful signal — and it's available before the page renders. Think of the filename as the foundation and alt text as the reinforcement. Optimizing both gives you the full signal stack.
Only if the SKU is itself a searched term. For some B2B products, the model number or part number is exactly what buyers search — in that case, including it makes sense: bosch-gbh-2-28f-rotary-hammer.webp. For most consumer products, descriptive words perform better than internal IDs. Never use the SKU as the only identifier: SKU-40291.jpg gives Google nothing.
Complete your image SEO — every signal, optimized.