BlurHash Generator - Compact Image Placeholder
Image Tools
Encode local images into BlurHash strings, or paste a hash to decode its placeholder. Adjust component detail and preview contrast in your browser.
Images are read and encoded in this browser; the file is not uploaded.
How to use this tool
- Upload an image using the file picker or drag-and-drop.
- Adjust the X components and Y components sliders if needed.
- Compare the decoded BlurHash preview and adjust punch if desired.
- Copy the generated BlurHash string for use in your project.
What is BlurHash?
BlurHash was created by Dag Agren at Wolt. It uses a discrete cosine transform (DCT) to encode an image’s broad color and shape patterns into a compact base83 string. Decoding that string creates a small, blurry placeholder for the time before a full image loads. BlurHash removes much of the fine detail, but it can still reveal broad colors or layout; treat it as a loading preview, not as a privacy boundary.
Integration examples
Choose Encode image to create a hash from a local file, or choose Decode hash to inspect an existing string without the original image. The tool processes files in your browser and does not upload them. Adjust X and Y components to trade a shorter string for more detail, then compare the original with the decoded placeholder. The punch control changes contrast in the preview only; it does not change the copied hash.
Your hash can be decoded in the browser using the blurhash npm package, or on the server using Swift/Kotlin/Go libraries. Frameworks like Next.js Image and Astro also support BlurHash placeholders.
X and Y component parameters
The X and Y component values control how much spatial detail is encoded in the hash, and directly affect the exact output length. The formula is 4 + 2 × (X × Y): two flag characters, four characters for the average color, and two characters for each remaining component. For example, 4 × 3 components produce exactly 28 characters, while 8 × 6 produce 100:
| Components (X × Y) | Exact hash length | Detail level | Typical use |
|---|---|---|---|
| 2 × 2 | 20 characters | Minimal - solid color gradient | Tiny thumbnails, avatar placeholders |
| 4 × 3 | 28 characters | Default - recognizable blur | General images, blog photos |
| 6 × 4 | 52 characters | Good - distinct shapes visible | Hero images, product photos |
| 8 × 6 | 100 characters | High - fine detail in blur | When longer hash is acceptable |
Higher component counts produce longer strings and can preserve more detail, but the visible improvement depends on the image and the size of its placeholder. A 4 × 3 hash is a practical starting point for many photos; use a portrait-shaped component grid for portrait imagery and compare the decoded preview before adopting a larger hash. Hash length grows quickly, so select the smallest grid that looks good in the space where the placeholder will appear.
Performance impact
Decoding a BlurHash and rendering it to a small canvas is usually inexpensive for typical component counts. Keep the image’s intended aspect ratio when you decode so the placeholder does not look stretched. A common loading pattern is:
-
Render the decoded BlurHash as a CSS
background-imageon a container element. - Load the real image behind it with
loading="lazy". - Once the image loads, fade out the BlurHash canvas or remove it from the DOM.
This approach eliminates layout shift (the space is pre-occupied) and provides a visually pleasant loading experience with near-zero performance overhead.
Frequently asked questions
What is BlurHash?
BlurHash is a compact base83 string that represents the broad colors and shapes of an image. Decode it into a small placeholder while the full image loads. It can still reveal broad color and layout cues, so it is not a privacy boundary.
How do I use the hash in my website?
Decode the hash in JavaScript (using a library like "blurhash"), render it to a canvas or CSS gradient, and show it in place of the `<img>` until the real image has loaded.
What do the X and Y component values affect?
Higher values can add spatial detail and make the hash longer. The exact length is 4 + 2 × (X × Y), so a 4×3 hash is 28 characters. Compare the decoded preview and choose the smallest grid that works for your image.
Does punch change the BlurHash string?
No. Punch changes contrast only while decoding the preview. The hash stays the same, so it does not need to be stored or shared separately.
Related tools
- Image CompressorOptimize the full image that will replace the compact placeholder after loading.
- Image ResizerPrepare responsive image dimensions to pair with the generated placeholder.
- Color ExtractorExtract a simpler dominant-color fallback for clients that do not render BlurHash.
- Image to Base64Compare BlurHash with an inline data-URL placeholder for the same asset.
- Data URICreate an inline image data URI when you need image bytes instead of a BlurHash.