How YouTube Thumbnail URLs Work
Technical reference for YouTube's thumbnail URL structure, quality suffixes, and programmatic access patterns.
URL Structure
Every YouTube thumbnail follows a predictable URL pattern:
https://img.youtube.com/vi/{VIDEO_ID}/{QUALITY_SUFFIX}.jpg
Components:
- Domain:
img.youtube.com— YouTube's dedicated image CDN - Path prefix:
/vi/— Stands for "video image" - Video ID: The 11-character YouTube video identifier (e.g.,
dQw4w9WgXcQ) - Quality suffix: Determines which thumbnail variant is returned
- Extension: Always
.jpg(JPEG format)
Quality Suffixes
| Suffix | Quality Name | Dimensions | Aspect Ratio |
|---|---|---|---|
default | Default | 120 × 90 | 4:3 |
mqdefault | Medium Quality | 320 × 180 | 16:9 |
hqdefault | High Quality | 480 × 360 | 4:3 |
sddefault | Standard Definition | 640 × 480 | 4:3 |
maxresdefault | Maximum Resolution | 1280 × 720 | 16:9 |
Complete Examples
For video dQw4w9WgXcQ (Rick Astley - Never Gonna Give You Up):
# Default (120x90)
https://img.youtube.com/vi/dQw4w9WgXcQ/default.jpg
# Medium Quality (320x180)
https://img.youtube.com/vi/dQw4w9WgXcQ/mqdefault.jpg
# High Quality (480x360)
https://img.youtube.com/vi/dQw4w9WgXcQ/hqdefault.jpg
# Standard Definition (640x480)
https://img.youtube.com/vi/dQw4w9WgXcQ/sddefault.jpg
# Maximum Resolution (1280x720) - only if available
https://img.youtube.com/vi/dQw4w9WgXcQ/maxresdefault.jpg
How Our Downloader Retrieves Thumbnails
The tool uses a two-step process:
- YouTube Data API v3 — We call
videos.listwithpart=snippetto:- Validate the video exists and is public
- Retrieve metadata (title, channel, duration, view count)
- Confirm the video ID is correct
- Direct URL construction — We construct the five thumbnail URLs using the known pattern. We then verify each exists with a
HEADrequest before displaying it. This avoids showing broken images for unavailable qualities (especiallymaxresdefault).
This approach is faster and more reliable than parsing HTML or using unofficial APIs.
Programmatic Access (For Developers)
Simple URL construction (no API key needed)
const videoId = 'dQw4w9WgXcQ';
const qualities = ['default', 'mqdefault', 'hqdefault', 'sddefault', 'maxresdefault'];
const urls = qualities.map(q =>
`https://img.youtube.com/vi/${videoId}/${q}.jpg`
);
Then check availability with a HEAD request:
async function checkThumbnailExists(url) {
try {
const res = await fetch(url, { method: 'HEAD' });
return res.ok;
} catch {
return false;
}
}
// Usage
for (const url of urls) {
if (await checkThumbnailExists(url)) {
console.log('Available:', url);
}
}
Using YouTube Data API (requires API key)
// Fetch video metadata + confirm video exists
const response = await fetch(
`https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=${videoId}&key=${API_KEY}`
);
const data = await response.json();
const video = data.items[0];
if (!video) throw new Error('Video not found or private');
// Thumbnail URLs from snippet.thumbnails object
const thumbnails = video.snippet.thumbnails;
// Contains: default, medium, high, standard, maxres (if available)
// Each has: url, width, height
CORS & Hotlinking Considerations
- Hotlinking allowed: YouTube's
img.youtube.compermits direct embedding and hotlinking - CORS headers: The CDN typically doesn't send
Access-Control-Allow-Origin, so browserfetch()from a different origin may fail - Workaround: Our downloader fetches the image server-side or uses blob URLs for downloads
tags work fine: Browsers allow cross-origin images inwithout CORS
Alternate Domains (Legacy)
You may encounter these older domains — they still work but img.youtube.com is the canonical domain:
i.ytimg.com— Legacy, redirects to img.youtube.comi1.ytimg.comthroughi4.ytimg.com— Old sharded CDN hosts
All resolve to the same infrastructure. Use img.youtube.com for new implementations.
Related Resources
- YouTube Thumbnail Downloader — Our tool handles all this automatically
- Thumbnail Sizes & Dimensions — Complete reference table
- How to Download YouTube Thumbnails — Step-by-step guide
- YouTube Thumbnail Guide — Best practices & design