PNG Color Count Finder

Scans every pixel of an uploaded PNG in your browser and counts the number of visually distinct colors it uses, both including and ignoring the alpha channel, and reports whether the color count is low enough to fit a 256-color indexed palette. Nothing is uploaded to a server. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool answers a specific question useful for optimizing image assets: exactly how many distinct colors does this PNG actually use?

It scans every pixel in your browser and reports the count directly, with no server upload involved.

What Is PNG Color Count Finder?

A pixel-level color counter that builds a set of every distinct color found in a decoded PNG, reporting both a full RGBA count (alpha included) and an RGB-only count (alpha ignored).

It also flags whether the RGBA color count is low enough (256 or fewer) to fit a lossless indexed-palette PNG.

How PNG Color Count Finder Works

After the uploaded PNG is decoded into an RGBA pixel buffer, a pure lib function loops over every pixel once, adding its packed RGBA value to one set and its packed RGB value (alpha dropped) to a second set.

The final size of each set is the distinct color count; comparing the RGBA set's size against 256 produces the indexed-palette flag.

When To Use PNG Color Count Finder

Use it before converting an image to a limited-palette format like indexed PNG or GIF, to check it will fit without color loss.

It's also useful for auditing whether flat icon/logo art is truly flat, or has picked up unwanted gradient noise from a previous export or resize.

Often used alongside PNG Analyzer and PNG Grayscale Checker.

Features

Advantages

  • Counts real pixel colors directly, rather than relying on a file's declared color type (which can be RGBA even for genuinely flat art).
  • Separates alpha-inclusive and alpha-exclusive counts, useful for different downstream decisions.
  • Runs entirely client-side, so the image is never uploaded anywhere.

Limitations

  • Doesn't identify or list which colors are used, only how many — for that, sample individual pixels in an image editor.
  • Scanning a very large image (near the 4096px cap other PNG tools in this category share) can take a brief moment.

Examples

Two-tone logo

Input

A 200x200 PNG logo in one solid brand color plus transparency

Output

Unique colors: 1, fits indexed palette: true

Flat single-color art has exactly one RGB value, easily fitting well under the 256-color indexed limit.

Gradient background

Input

A 512x512 PNG with a smooth color gradient

Output

Unique colors: several thousand, fits indexed palette: false

Smooth gradients generate many closely-related but distinct color values, quickly exceeding 256.

Best Practices & Notes

Best Practices

  • Check the color count before choosing between full RGBA PNG and an indexed/limited-palette export to avoid unexpected banding.
  • If a flat-color asset reports far more colors than expected, look for anti-aliased edges as the likely cause.

Developer Notes

The color-counting loop is a pure function over a plain Uint8ClampedArray pixel buffer using JS Sets keyed by a packed numeric color value, fully unit-tested without any canvas dependency; only decoding the upload into that buffer happens in the browser-only component.

PNG Color Count Finder Use Cases

  • Checking whether an image can be losslessly converted to an indexed-palette or GIF format
  • Auditing flat icon/logo art for unwanted anti-aliasing noise
  • Comparing the color complexity of two candidate image exports

Common Mistakes

  • Assuming a PNG saved from an editor with an 'RGBA' color type must have many colors — the actual pixel data can still be very simple.
  • Expecting a photo to have a low color count; continuous-tone images naturally report thousands of distinct values.

Tips

  • If you need a small file size and the color count is high, consider whether a JPEG (for photos) or a color-reduced PNG (for graphics) is more appropriate.
  • Use uniqueOpaqueColors specifically when you only care about visible hues and want alpha variation ignored.

References

Frequently Asked Questions