Photonamus Industries Forums
Pixel Art in ComfyUI - Printable Version

+- Photonamus Industries Forums (https://forum.photonamus.com)
+-- Forum: AI & Machine Learning (https://forum.photonamus.com/forumdisplay.php?fid=32)
+--- Forum: Public AI Context Library (https://forum.photonamus.com/forumdisplay.php?fid=33)
+--- Thread: Pixel Art in ComfyUI (/showthread.php?tid=53)



Pixel Art in ComfyUI - Photonamus - 08-23-2026

Pixel Art in ComfyUI — Context Document

AI-assisted pixel art generation using ComfyUI workflows, LoRAs, and custom nodes

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This context document turns an AI assistant into a knowledgeable guide for generating authentic pixel art using ComfyUI. It covers the two main generation approaches (top-down recommended vs bottom-up), the best models and LoRAs for the job, and the custom node ecosystem that makes clean pixel art output possible.

The document includes detailed coverage of PixelArt Detector, Unfake Pixels, AI Pixel Art Enhancer, and other custom nodes — what each one does, how to configure it, and when to use which. It walks through exact dimension control techniques for img2img same-size output, proper KSampler settings, prompting strategies with era-specific constraints, and palette management best practices.

─── ◆ ───

What It Covers
  • Two generation approaches — top-down (generate at native resolution, downscale with nearest-neighbor) vs bottom-up (generate at target resolution directly), with clear guidance on why top-down wins
  • Models and LoRAs — Pixel Art XL, Sprite Shaper, Hard Edge (Flux), and Retro Diffusion with trigger words and weight recommendations
  • Custom node reference — six nodes from PixelArt Detector, Unfake Pixels edge-aware auto-scaling, AI Pixel Art Enhancer methods, and more
  • Exact dimension control — five techniques for getting precise output sizes including the Resize Sandwich, VAE encode at native res, and external ImageMagick
  • Generation resolution table — target size to generation resolution mapping with scale factors
  • Prompting and palette management — positive/negative prompt templates, era constraints (NES, SNES, Game Boy, modern), Lospec palette integration
  • Sprite sheet workflow — LoRA training, batch generation, background removal, grid arrangement, and validation
  • Critical rules — nearest-neighbor only, PNG only, integer multiples only, palette discipline

─── ◆ ───

How to Use It

Paste the contents of the document into a new conversation as context, or attach the file directly. The AI will then have detailed knowledge of ComfyUI pixel art workflows, node configurations, proper scaling techniques, and palette management — enough to help you build and troubleshoot complete pixel art generation pipelines.

The document is workflow-agnostic and works with any ComfyUI setup. All custom nodes referenced are open source with installation commands included.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Document Contents

Code:
# Pixel Art in ComfyUI — Context Reference ## Two Approaches **Top-Down (Recommended):** Generate at model-native resolution (512×512 SD1.5, 1024×1024 SDXL/Flux) with pixel art LoRA → nearest-neighbor downscale to target (÷8, ÷16) → palette quantize. Best results, most reliable. **Bottom-Up:** Generate at target resolution directly (32×32, 64×64). Mostly fails — latent space too small (64×64 = 8×8 latent). Only viable with specialized models or heavy ControlNet guidance with low denoise. ## Models & LoRAs **Pixel Art XL LoRA v1.1 (NeriJS)** — Gold standard. SDXL 1.0 base. No trigger word. Weight 1.0–1.2. Don't use SDXL refiner. Works with 1 text encoder. Downscale 8× with nearest-neighbor for pixel-perfect output. `civitai.com/models/120096/pixel-art-xl` **Pixel Art Diffusion XL — Sprite Shaper** — Full SDXL checkpoint for 16-bit style. `civitai.com/models/277680` **Hard Edge Pixel Art LoRA** — Flux.1 Dev compatible. Trigger: "pixel art". Harder edges than SDXL LoRAs. **Retro Diffusion** — Purpose-built pixel art model (cloud service, not local). Dramatically better than general models. `retrodiffusion.ai` ## Key Custom Nodes **ComfyUI-PixelArt-Detector (dimtoneff)** — 6 nodes. MIT license. `github.com/dimtoneff/ComfyUI-PixelArt-Detector` - PixelArt Detector (+Save): all-in-one reduce/resize/save - PixelArt Detector (Image→): downscale + reduce, forward to next node - PixelArt Palette Converter: swap palettes. Methods: Image.quantize (fast, MAXCOVERAGE best for pixel art), Grid.pixelate, NP.quantize, OpenCV.kmeans, Pycluster.kmeans/kmedians - PixelArt Palette Loader: Lospec palettes with visual preview - PixelArt Palette Generator: extract palette from image → color list output - PixelArtAddDitherPattern: prepared + custom patterns - Resize modes (v1.7.0+): "contain" (default, preserves AR), "fit" (crop to fill), "stretch" (exact dims, may distort). Set W&H to 0 to disable. - cleanup_pixels_threshold: 0.01–0.05 eliminates stray colors. Lower = more colors kept. **ComfyUI-Unfake-Pixels (tauraloke)** — Edge-aware auto-scale. Sobel filter + tile voting detects true pixel size of AI output, downscales to real grid. `github.com/tauraloke/ComfyUI-Unfake-Pixels` - downscale_method: "nearest" (crisper) or "dominant" (smoother) - cleanup_jaggies: removes isolated noise pixels **ComfyUI-PixelArt-Unfaker** — Enhanced fork. Adds exact target resolution (target_width/target_height), auto background removal, optimal crop/center to pixel grid, K-Means quantization. `github.com/ComfyNodePRs/PR-ComfyUI-PixelArt-Unfaker-4f850341` **ComfyUI-AI-Pixel-Art-Enhancer (HSDHCdev)** — Output resolution always matches input. Grain sizing control. Palette input forces exact color mapping. Methods: most_frequent (logos/UI), average (portraits), edge_preserving (graphics), neighbor_aware (landscapes). `github.com/HSDHCdev/ComfyUI-AI-Pixel-Art-Enhancer` **comfy_pixelization (filipemeneses)** — AI-based, higher quality. NON-COMMERCIAL license. Requires 3 checkpoint downloads. **WAS Node Suite** — Commercial-safe pixelization. Slower, less refined than AI-based. ## Exact Dimension Control (img2img same-size output) **Technique 1 — Resize Sandwich (most reliable):** Load Image → upscale to model res with nearest-neighbor at integer multiple (64×64 → 512×512 = 8×) → VAE Encode → KSampler (denoise 0.3–0.6) → VAE Decode → downscale back with nearest-neighbor (÷8) → palette quantize → save. Upscale factor MUST be integer. Same factor up and down. **Technique 2 — VAE Encode at native res (subtle changes only):** Load 64×64 → VAE Encode (8×8 latent) → KSampler denoise 0.1–0.3 → VAE Decode → output 64×64. No resize needed. Only for palette shifts/subtle style transfer. **Technique 3 — PixelArt Detector pipeline:** Use PixelArt Detector (Image→) with resize_w/resize_h set to target. "stretch" mode forces exact dims. **Technique 4 — Unfaker pipeline:** Set target_width/target_height → auto grid detect → crop/align → downscale → pad/crop to exact target. **Technique 5 — External ImageMagick:** `magick convert input.png -resize 64x64\! -filter point output.png` `\!` = force exact dims. `-filter point` = nearest-neighbor. ## Generation Resolution Table | Target | Generate At | Scale Factor | |---|---|---| | 16×16 | 512×512 | ÷32 | | 32×32 | 512×512 | ÷16 | | 64×64 | 512×512 | ÷8 | | 128×128 | 1024×1024 | ÷8 | | 256×256 | 1024×1024 | ÷4 | ## KSampler Settings Steps: 20–30. CFG: 5–8 (lower = more natural). Sampler: dpm++ 2m karras or euler_a. Scheduler: karras. Denoise: 1.0 txt2img, 0.3–0.5 img2img (preserve structure), 0.6+ heavy restyle. ## Prompting **Positive:** `pixelart, {scene}, pixel-art, low-res, blocky, pixel art style, 8-bit graphics, sharp details, less colors, early computer game art` **Negative:** `sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic, high-resolution, photo-realistic, 3d render, depth of field, anti-aliasing, smooth shading, gradient` **Era constraints:** NES: `4 colors, 32×32` | SNES: `16 colors, 64×64` | Game Boy: `4 shades green monochrome` | Modern: `128×128+, detailed shading` ## Palette Management Palette quantization must happen INSIDE workflow, not as afterthought. Insert Palette Quantize inside KSampler loop to prevent out-of-gamut color propagation. Sources: Lospec (`lospec.com/palette-list`), bundled PixelArt Detector palettes (NES, Game Boy, etc.), custom 1px-per-color images in palettes/1x directory. Extract palette from existing art: PixelArt Palette Generator node or AI Pixel Art Enhancer (32×32 swatch grid output). ## Sprite Sheets 1. Train character LoRA (15–20 refs, lr ~0.0002, 15–20 epochs) for consistency 2. Batch generate individual frames with pose-specific prompts, same LoRA/sampler/palette 3. Background removal: Rembg (fast/good enough), SAM2 (better edges), or color-based 4. Grid arrangement via Image Grid node or Python script 5. Validate: identical dims + palette across all frames - Same seed for related frames. Canvas Align node to center at fixed dims before save. No auto-crop. ## Sprite Size Reference | Era | Size | Colors | Frames | |---|---|---|---| | NES/8-bit | 8–16px | 3–4 | 2–4 | | SNES/16-bit | 16–32px | 16–24 | 4–8 | | GBA/32-bit | 32–64px | 16–32 | 6–8 | | Modern indie | 32–128px | 32+ | 8–12 | 32×32 is the sweet spot for AI generation. ## Critical Rules - ALWAYS use "nearest-exact" interpolation for any pixel art scaling. Never bilinear/bicubic/lanczos. - Save as PNG only. Never JPEG for pixel art. - Integer multiples only for up/downscaling. Never fractional. - Pixel art scaling must be integer only: 2×, 3×, 4×. Never 1.5×. - Palette discipline is the #1 differentiator between fake and real pixel art. ## Node Installation ``` git clone https://github.com/dimtoneff/ComfyUI-PixelArt-Detector git clone https://github.com/tauraloke/ComfyUI-Unfake-Pixels git clone https://github.com/HSDHCdev/ComfyUI-AI-Pixel-Art-Enhancer git clone https://github.com/filipemeneses/comfy_pixelization  # non-commercial git clone https://github.com/WASasquatch/was-node-suite-comfyui ```

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Download the .zip below to use this document with your AI assistant.