PNG Edges Cleaner

Uploads a PNG and removes stray, isolated non-transparent pixels near its edges: any pixel with fewer than a chosen number of non-transparent 8-connected neighbors is treated as noise and made fully transparent, then lets you download the despeckled PNG. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool cleans up stray, isolated pixels near a PNG's edges, entirely client-side, using a simple neighbor-counting despeckle pass.

It's useful for tidying up single-pixel artifacts left behind by a lossy background-removal or masking step.

What Is PNG Edges Cleaner?

A client-side PNG despeckling tool that examines each non-transparent pixel's 8 surrounding neighbors and removes (makes fully transparent) any pixel that doesn't have enough non-transparent neighbors to be considered part of a real shape.

It's a simple morphological cleanup pass, distinct from blurring (which softens everything) or thresholding (which only looks at a pixel's own alpha value).

How PNG Edges Cleaner Works

For each non-transparent pixel, the tool counts how many of its 8 surrounding pixels (up, down, left, right, and the four diagonals) are also non-transparent.

If that count is below the chosen minimum-neighbors setting, the pixel is treated as noise and its alpha is set to 0; otherwise it's left completely unchanged.

When To Use PNG Edges Cleaner

Use it after background removal or masking to clean up leftover single-pixel or few-pixel specks that weren't fully caught by the main operation.

It's also useful as a quick sanity pass before compositing a cutout onto a new background, where stray specks would otherwise be visible.

Often used alongside PNG Edges Refiner and PNG Background Remover.

Features

Advantages

  • Runs entirely client-side; the uploaded image is never sent to a server.
  • Targets isolated noise specifically, without blurring or thresholding the rest of the image.
  • Adjustable sensitivity via the minimum-neighbors setting.

Limitations

  • A high minimum-neighbors setting can also erode thin, legitimately-isolated details like fine hair strands or single-pixel-wide lines.
  • It only considers each pixel's immediate 8-neighbor ring, so small clusters of 2-3 noise pixels that reinforce each other's neighbor count may survive.

Examples

Remove a single stray speck

Input

A cutout PNG with one isolated opaque pixel floating in transparent space, minNeighbors 2

Output

That pixel becomes fully transparent; the main subject is untouched

An isolated pixel with 0 non-transparent neighbors falls below the threshold of 2.

Preserve a solid shape's edge

Input

A filled circle shape, minNeighbors 2

Output

The circle's edge and interior pixels remain fully intact

Edge pixels of a real shape have enough non-transparent neighbors along the boundary to survive.

Best Practices & Notes

Best Practices

  • Start with the default minimum-neighbors value of 2, which removes fully isolated specks without eroding real edges.
  • If your subject has fine, thin details (hair, whiskers, thin lines), use a lower minimum-neighbors value or skip this step for those images.

Developer Notes

cleanPngEdges is a pure lib function operating on a plain Uint8ClampedArray PixelBuffer: for each non-transparent pixel it counts non-transparent pixels among its 8-connected neighbors and zeroes the alpha of any pixel below the configured threshold — no DOM access until the component paints the result for preview/download.

PNG Edges Cleaner Use Cases

  • Cleaning up single-pixel artifacts left after background removal
  • Tidying a mask before compositing it onto a new background
  • Removing sensor-noise-style specks from a scanned or photographed cutout

Common Mistakes

  • Setting the minimum-neighbors threshold too high and accidentally eroding thin, legitimate details like hair or fine lines.
  • Expecting this to fix color fringing — it only removes isolated pixels based on alpha, not color.

Tips

  • Run this before the edge softener tool for the cleanest final result: despeckle first, then feather what remains.
  • Use the transparency checker tool afterward to confirm how much of the image's non-opaque area changed.

References

Frequently Asked Questions