Everything in pixels. Everything in code.
PixelKit is an open-source toolkit for turning high-detail images into pixel art that is ready for a game: the right size, a limited palette, crisp edges and clean clusters, produced the same way every time, on your own machine.
0: source picture. 1: box-average resize plus median-cut palette, the way most "pixelate" filters work. 2: PixelKit 0.1.0 with its default settings. Both pixel-art versions are 128 px tall with 32 colours, shown at 3×.
| Package | What it does | Status |
|---|---|---|
@techbypixel/pixelkit |
Image-to-pixel-art conversion: palette-first voting in OKLab, cleanup, optional outline and ordered dithering | 0.1.0 on npm |
The first release does one thing: conversion. More tools (editing, palettes, sprite sheets, export to game engines) will follow only once the conversion quality has been proven on more kinds of pictures.
import { convert } from "@techbypixel/pixelkit";
const { image, palette } = convert(imageData, { height: 128, colours: 32 });See the package README for every option, the building blocks, how the algorithm works and its limits.
The same comparison on seven more AI-generated test pictures from apps/benchmark/public/inputs: the source (0), a classic resize-and-reduce filter (1) and PixelKit 0.1.0 with its default settings (2), each 128 px tall with 32 colours, shown at 3×. They are visual comparisons only; the numbers in the package README come from the character and weapon pictures.
Flat vector style: the filter blurs the dark outlines into grey, while PixelKit keeps flat fills and solid outlines.
3D render: PixelKit keeps the gold trim crisper and the highlights brighter. The small red gem is lost in both versions.
Glass: the highlights on the bottle stay sharper.
Photograph: PixelKit turns the canvas texture into speckled noise, while the filter's averaging gives a smoother fill. Photographs are not what PixelKit is tuned for yet.
Thin lines: the bowstring is 2–3 px wide in the source, about a fifth of an output pixel at this size, and disappears in both versions; the chains on the staff break into loose dots.
Soft glow: the semi-transparent aura becomes a solid pale ring around the creature in both versions.
pixelkit/
├── packages/
│ └── pixelkit/ @techbypixel/pixelkit: the library (TypeScript, no dependencies)
├── apps/
│ └── benchmark/ Interactive page and scripts comparing nine conversion pipelines on the same pictures
└── docs/images/ Pictures used in this README
The benchmark imports the library's own functions for every step the library has, so pipeline 8 on the benchmark page gives exactly the pixels of convert(). The other pipelines are kept for comparison.
Requirements: Node.js 24 (the scripts run TypeScript files directly) and pnpm 11.
pnpm install
pnpm test # tests of the library and the benchmark
pnpm typecheck
pnpm build # builds packages/pixelkit
pnpm dev # benchmark page at http://localhost:3210
pnpm bench # writes contact sheets and numbers to apps/benchmark/benchmark-resultsDuring development the benchmark resolves @techbypixel/pixelkit to the library's TypeScript sources through the @techbypixel/source export condition, so the library does not need to be rebuilt after every change.
The page shows a source picture and the result of each pipeline side by side, at native size and enlarged, and lets you change the frame height, palette, quantizer, downsampling method, dithering, outline and cleanup. You can drop in any picture of your own; it never leaves the browser.
The fixed set of test pictures in apps/benchmark/public/inputs is part of the repository and covered by the same MIT licence as the code, so you can use it for your own comparisons.
Issues and pull requests are welcome. Before opening a pull request:
- Run
pnpm testandpnpm typecheck. - If you change the algorithm, run
pnpm benchand compare the contact sheets before and after: a change that improves a number but makes the pictures look worse is not an improvement. - Keep the library free of runtime dependencies and of DOM or Node APIs.
Commit messages follow Conventional Commits.
MIT © TechByPixel