Blurhash URL
What is a Blurhash URL?
A Blurhash URL is an image URL with embedded placeholder data. It encodes everything needed to render a beautiful Blurhash placeholder — dimensions, Blurhash data, and fallback color — directly in the image URL.
This eliminates the need for separate API calls to fetch placeholder data, enabling faster initial page renders and a smoother visual loading experience. You can use Blurhash URLs to replace your existing image URL fields — no database migrations or additional columns required.
At a glance
- URL-powered placeholders: Enables rapid-render image placeholders and optimized web vitals (via visionary-image).
- Cache-friendly: Deterministic URLs with path-based encoding maximize browser and CDN cache hits.
- Universal: Works in browsers, Node.js, and worker environments.
- Lightweight: The blurhash-url npm package is under 3 kB minzipped.
Anatomy of a Blurhash URL
cmhEMTdzeGo0MCEzNDg4ITYyMDAhZjg4YTdiIUtlUT1-c3hHXjZ2Q2Y3Uit9c2p0OV0hMyEz
/sunset-palm-tree.jpg
decodedBlurhash
{
backgroundColor: "#f88a7b",
blurhash: "KeQ=~sxG^6vCf7R+}sjt9]",
blurhashX: 3,
blurhashY: 3,
}
A Blurhash URL consists of 3 or 4 path segments:
| Base path | Blurhash Code | Options (optional) | Filename | |||
|---|---|---|---|---|---|---|
/image | / | <base64url-encoded placeholder data> | / | <option tokens> | / | image.jpg |
Example Blurhash URL
https://blurhash.link/image/
aW1nIzQyITk2MCE3MjAhODY5NmFjIUFVRlpULiVMX04lMSEyITI/image.jpg
The bold section is the encoded Blurhash Code containing the placeholder data.
Blurhash Code
The Blurhash Code is a base64url-encoded string containing the following fields (in order):
| Index | Attribute | Description |
|---|---|---|
0 | Image URL / ID | The URL of the image or an internal image ID. Required. |
1 | Image width | Used to calculate aspect ratio and constrain placeholder width. Required. |
2 | Image height | Used to calculate aspect ratio and constrain placeholder height. Required. |
3 | Background color code | Base layer color (e.g. |
4 | Blurhash code | Blurhash code for the image. |
5 | Alt text | Optional alt text for accessibility. |
The first three fields (image ID, width, and height) are required to render a properly sized placeholder. If the other fields are omitted, a placeholder with a semi-transparent black background (rgba(0, 0, 0, 0.7)) will be rendered.
Fields are separated by an exclamation mark (!) before being base64url-encoded. This separator was chosen to avoid conflicts with characters used by Blurhash’s base83 encoding.
Image Options
Image options control how the image is served. To add them, include comma-separated tokens in the URL segment between the Blurhash Code and the filename.
/image/djQyITEyODAhODUzITg2OTZhYw/<options>/image.jpg
Options should be sorted alphabetically (e.g., download,jpeg not jpeg,download) to ensure consistent URLs for the same set of options. This maximizes cache hit rates across browsers and CDNs. When you generate URLs with blurhash-url, options are automatically sorted.
Example: Options tokens instructing the server to return an xl sized image as a downloadable file:
https://blurhash.link/image/djQyITEyODAhODUzITg2OTZhYw/download,xl/image.jpg
Format Tokens
Specify the image format using one of the following tokens:
| Token | Description |
|---|---|
auto | Selects the most ideal format based on the browser’s |
avif | Force the image to be served as AVIF. Best compression, widest modern browser support. |
jpeg | Force the image to be served as JPEG. Universal compatibility. |
webp | Force the image to be served as WebP. Good compression with broad browser support. |
Control Tokens
| Token | Description |
|---|---|
debug | Instructs the server to display debug information for this URL. |
download | Instructs the server to set |
follow | Instructs the server to issue a redirect and follow the URL field for external URLs on whitelisted domains. |
Image Resolutions
Specify the image resolution using a size token in the options segment. The size token constrains the image’s longest edge (width or height) to the specified pixel value, preserving the original aspect ratio.
For example, a 4k token applied to a 6000×4000 landscape image produces a 3840×2560 output. The same token applied to a 4000×6000 portrait image produces a 2560×3840 output.
Size Token Reference
| Token | Long Edge (px) | Name | Common Use |
|---|---|---|---|
xs | 160 | Tiny | Micro-thumbnails, avatar icons, tiny previews |
sm | 320 | Small | Thumbnails, mobile image grids, small cards |
md | 640 | Medium | Mobile full-width, email images, small embedded media |
lg | 1280 | Large | Standard desktop, blog hero images, content images. Default size. |
xl | 1920 | X-Large | Full HD displays, full-width desktop hero banners |
xxl | 2560 | XX-Large | QHD / 1440p displays, high-density Retina screens |
4k | 3840 | 4K | 4K UHD displays, large-format digital signage |
5k | 5120 | 5K | 5K Retina displays (e.g. Apple Studio Display), ultra-high-res |
full | Source | Full | Original source resolution, no downscaling applied |
Resolution Details
xs — 160px (Tiny)
Best for micro-thumbnails where image detail is not important. At 160px on the long edge, these are ideal for small avatar images, icon-sized previews, or image list indicators. Produces the smallest file sizes for maximum performance.
sm — 320px (Small)
Suitable for thumbnail grids and small card images. At 320px, this covers typical thumbnail sizes used in galleries, search results, and small mobile layouts. Roughly equivalent to an older smartphone screen width.
md — 640px (Medium)
A versatile mid-range size. At 640px, images look sharp on mobile devices at full viewport width and work well for email content, social sharing previews, and embedded media in articles. Close to classic VGA resolution (640×480).
lg — 1280px (Large) — Default
The default size token. At 1280px, images are sharp on standard desktop monitors and laptops. This corresponds to HD-class resolution (1280×720 / 720p) and covers the majority of standard web use cases: blog posts, product pages, and content images. A good balance between quality and file size.
xl — 1920px (X-Large)
Matches Full HD resolution (1920×1080 / 1080p), the most common desktop display resolution worldwide. Ideal for full-width hero banners, landing page backgrounds, and full-viewport desktop images. Sometimes referred to as “2K” in consumer contexts, though true DCI 2K is 2048×1080.
xxl — 2560px (XX-Large)
Covers QHD (Quad HD) resolution, also known as 1440p or WQHD (2560×1440). Common on high-end desktop monitors, gaming displays, and 13–14“ Retina laptop screens where the OS renders at an effective 1280px at 2× density. Also covers 2K in the professional cinema sense (2560×1440).
4k — 3840px
4K UHD (Ultra High Definition), the resolution of modern 4K TVs and monitors (3840×2160). Also covers the true DCI 4K cinema standard (4096×2160) when images are wide enough. Use this for large-format displays, digital signage, or when serving images on high-density screens at large viewport sizes.
5k — 5120px
5K resolution (5120×2880), found on displays like the Apple Studio Display and iMac Retina. This resolution enables pixel-perfect rendering at an effective 2560px at 2× Retina density. Use for ultra-high-resolution use cases where maximum detail is required.
full — Source Resolution
Serves the image at its original uploaded resolution with no downscaling. Use when you need the exact source quality — for example, for download links, print preparation, or when users need access to the highest-resolution version available.
Filename
The last path segment is the filename. Defaults to image.jpg.
Use descriptive filenames (e.g. tokyo-shibuya-crossing-neon-rainy.jpg) to improve image discoverability in search engines.
The filename can also be modified to force a cache refresh. If an outdated image is still being served due to caching, append a version number or date (e.g. starship-stacked-v2.jpg or starship-stacked-20250609.jpg) to ensure the latest version is loaded.
Using Your Own Domain
To configure your domain to serve Blurhash URLs, simply set up two routes in your server:
app.get("/image/:blurhashCode/:filename", handler);
app.get("/image/:blurhashCode/:options/:filename", handler);
The handler extracts the Blurhash placeholder data from the URL and serves the corresponding image:
import { parseVisionaryString } from "blurhash-url";
export const handler = (request: Request) => {
const data = parseVisionaryString(request.url);
const imageUrl = data.fields.url;
// Load, serve, or redirect your image as needed
};
Back to top