Home › Developer Tools › CSS Sprite Generator

CSS Sprite Generator

Add your icons or images and get one optimized sprite sheet plus the CSS classes that show each image with background-position. Choose packed, horizontal, vertical or grid layout, padding and retina scale; everything runs in your browser.

Last updated:

Add images or drop them herePNG, JPG, GIF, WebP, SVG · up to 300 images

Images 0

    Sprite sheet
    Hover or tap an image on the sheet to see its class.
    CSS
    
          
    Advertisement
    Advertisement

    How to use the CSS Sprite Generator

    1. Add images: choose or drop your icons (PNG, JPG, GIF, WebP or SVG). Sample icons are loaded so you can try it right away.
    2. Pick a layout (Packed gives the smallest sheet) and set the padding between images.
    3. Set the class prefix and the sprite file name used in the CSS url().
    4. Enable Retina @2x if your images are double size, so the CSS shows them at half size and sharp on high-density screens.
    5. Download the sprite PNG and CSS, or the ZIP that also includes a demo page.

    How to use the sprite CSS

    Upload the PNG next to your stylesheet (or change the file name to its real path), paste the CSS, and add both classes to an empty inline element:

    <span class="icon icon-home" role="img" aria-label="Home"></span>
    
    /* change the image on hover */
    .button:hover .icon-star { background-position: -52px -2px; }

    Every image keeps its own width and height, and background-position moves the sheet so only that image shows through. The values are negative because the sheet is shifted up and to the left.

    Choosing the right options

    OptionWhen to use it
    PackedMixed image sizes; produces the smallest sheet with a binary-tree packing algorithm.
    Horizontal / verticalAnimation frames (step through them with steps()) or same-size icons that should stay in order.
    GridIcon sets and flags of similar size; every image sits centered in an equal cell.
    Padding 2-4pxPrevents neighbouring images from bleeding in when the page is zoomed or scaled.
    Retina @2xYour source images are double resolution; CSS shows them at half size with background-size.

    Tip: compress the downloaded PNG with a PNG optimizer before publishing; sprite sheets with large transparent areas often shrink by 30-70%.

    Frequently asked questions

    What is a CSS sprite?

    A CSS sprite is a single image that contains many small images such as icons. Each element shows the same file as its background, and background-position shifts it so only the right part is visible. It reduces the number of image requests and avoids flicker when hover images load.

    Are CSS sprites still useful with HTTP/2?

    HTTP/2 makes many small requests cheaper, so sprites matter less than they used to. They are still handy for game graphics, emoji or flag sets, hover states that must appear instantly, and email or legacy environments. For simple single-color icons, SVG icons are often a better choice.

    Why add padding between images?

    When a sprite is scaled, zoomed or rendered at fractional pixel positions, the browser may sample pixels from the neighbouring image, showing thin lines at the edges. A few pixels of transparent padding prevents this bleeding.

    How does background-position work in a sprite?

    The position is negative: to show an icon that sits 64px from the left and 32px from the top of the sheet, use background-position: -64px -32px with the element sized to the icon's width and height.

    What does the Retina @2x option do?

    It assumes your source images are twice the size they should appear. The sheet keeps full resolution, while the CSS halves every width, height and position and sets background-size to half the sheet size, so icons look sharp on high-density screens.

    Which layout should I choose?

    Packed creates the most compact sheet for mixed sizes. Horizontal or vertical strips are easy to read and work well for icons of equal size or animation frames. Grid places equal cells in rows and columns, which suits icon sets.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.PNG to ICOCreate multi-size favicon .ico files from PNG.Favicon GeneratorMake a favicon.ico, PNG icons, apple-touch-icon and web manifest from an image, text or emoji.Pixel Art UpscalerUpscale pixel art and sprites crisply with nearest neighbor, Scale2x/3x or xBR, keeping transparency.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Tooltip GeneratorBuild pure CSS tooltips: position, arrow, colors, padding and animation. Copy HTML and CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.
    See all 52 Web, HTML & CSS Tools →