User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
Category CSS Tools
Drop image here or click to browse PNG, JPG, GIF, SVG, WebP
Larger images scaled down to this. Range: 8–256.
Size of each CSS pixel block. Range: 1–10.
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

About

CSS box-shadow accepts an arbitrary number of shadow layers. Each layer maps to one pixel: horizontal offset x, vertical offset y, zero blur, a spread equal to the pixel size, and the pixel's color. An image of w Γ— h pixels produces up to w β‹… h shadow declarations. A 64 Γ— 64 source generates up to 4096 entries. Output size grows quadratically with resolution. This tool reads raw RGBA data from a Canvas context, skips fully transparent pixels (Ξ± = 0), and selects HEX notation when Ξ± = 255 to minimize byte count. Processing runs inside a Web Worker so the interface stays responsive even on images exceeding 10 000 pixels.

Practical uses include pure-CSS sprites for email signatures, novelty portfolio pieces, and demonstrations of browser rendering limits. Note: most browsers degrade rendering performance above roughly 50 000 shadow layers. Keep source dimensions small. This tool approximates the original image under the assumption that each pixel maps to a uniform square of configurable size. Anti-aliased edges and sub-pixel detail are lost.

image to css box-shadow css art pixel art image converter css generator box-shadow generator

Formulas

Each opaque pixel at column c and row r with color channels R, G, B, A produces one shadow layer:

shadow = (c β‹… s)px (r β‹… s)px 0 spx color(R, G, B, A)

where s = pixel size in CSS pixels (default 1). The color function selects the shorter representation:

{
hex(R, G, B) if A = 255rgba(R, G, B, A255) if 0 < A < 255skip if A = 0

RGB to HEX conversion:

hex(R, G, B) = # + R.toString(16) + G.toString(16) + B.toString(16)

Total pixel count and output estimation:

N = w β‹… h βˆ’ Ntransparent

where w = image width in pixels, h = image height in pixels, Ntransparent = count of fully transparent pixels skipped, s = pixel size multiplier (1 - 10 px), R, G, B = red, green, blue channels (0 - 255), A = alpha channel (0 - 255).

Reference Data

Source Size (px)Max ShadowsApprox. CSS SizeBrowser RenderRecommended Use
16 Γ— 162565 - 8 KBInstantFavicons, tiny icons
32 Γ— 321 02420 - 35 KBInstantPixel art, emojis
48 Γ— 482 30445 - 75 KBFastAvatars, badges
64 Γ— 644 09680 - 130 KBFastThumbnails, sprites
96 Γ— 969 216180 - 300 KBModerate lagPortraits (simple)
128 Γ— 12816 384320 - 520 KBNoticeable lagDemos, experiments
192 Γ— 19236 864700 KB - 1.2 MBHeavy lagStress tests only
256 Γ— 25665 5361.3 - 2 MBMay freeze tabNot recommended
Color Format Comparison
HEX (#RRGGBB)7 bytes/colorOpaque pixels only (Ξ± = 255)
RGBA (rgba(R,G,B,A))18 - 24 bytes/colorSemi-transparent pixels
Transparent skip0 bytesPixels with Ξ± = 0 omitted entirely
box-shadow Syntax per Pixel
Full formXpx Ypx 0 Spx color - 5 tokens
Zero-offset form0 0 0 Spx color - units omitted on 0

Frequently Asked Questions

Each non-transparent pixel produces one box-shadow entry averaging 25 - 35 bytes. A 64 Γ— 64 image yields up to 4 096 entries, resulting in roughly 100 - 140 KB of CSS. Doubling the dimension quadruples the pixel count and CSS size. Keep source images under 128 pixels per side for practical use.
Pixels with alpha A = 0 are skipped entirely, reducing output size. Pixels with 0 < A < 255 use rgba() notation. Fully opaque pixels (A = 255) use shorter HEX notation. PNG images with transparency are handled correctly. JPEG images have no alpha channel so all pixels are treated as opaque.
The box-shadow property is supported in all modern browsers including Chrome, Firefox, Safari, and Edge. However, rendering performance degrades with large shadow counts. Chrome typically handles up to 50 000 shadows before noticeable lag. Firefox tends to be slightly slower. Internet Explorer 9 supports box-shadow but will struggle with more than a few hundred layers.
The tool caps input at 256 Γ— 256 pixels. Larger images are automatically scaled down while preserving aspect ratio. This limit exists because 65 536 shadow entries produce roughly 1.5 - 2 MB of CSS, which can crash browser rendering. For photographic images, 48 - 64 pixels produces the best balance between recognizability and performance.
Technically yes, but it is inadvisable for anything beyond decorative novelty. A single box-shadow rule with thousands of entries forces the browser to composite each layer independently on every repaint. This consumes significantly more GPU memory than an equivalent PNG or SVG. Use cases include CSS art showcases, email signatures where images are blocked, and technical demonstrations.
Iterating over every pixel and constructing the shadow string involves processing up to 65 536 pixels with string concatenation. On the main thread this would freeze the UI for several seconds on larger images. The Web Worker runs in a separate thread, posting progress updates back to the main thread so the progress bar updates smoothly without blocking user interaction.