<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jian Tang</title>
    <description>The latest articles on DEV Community by Jian Tang (@swordtang).</description>
    <link>https://dev.to/swordtang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4008449%2F266246b3-9114-4540-a3ce-c4d54b276b63.png</url>
      <title>DEV Community: Jian Tang</title>
      <link>https://dev.to/swordtang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swordtang"/>
    <language>en</language>
    <item>
      <title>I built a browser tool that turns any image into Minecraft pixel art</title>
      <dc:creator>Jian Tang</dc:creator>
      <pubDate>Mon, 29 Jun 2026 15:54:07 +0000</pubDate>
      <link>https://dev.to/swordtang/i-built-a-browser-tool-that-turns-any-image-into-minecraft-pixel-art-1hea</link>
      <guid>https://dev.to/swordtang/i-built-a-browser-tool-that-turns-any-image-into-minecraft-pixel-art-1hea</guid>
      <description>&lt;p&gt;I play a lot of Minecraft, and every time I wanted to build pixel art from an image I hit the same wall: manually matching each pixel to the closest block color, then counting how many of each block I'd need. For a 64×64 build that's 4,000+ blocks to plan by hand. So I built a tool to do it in a second — &lt;a href="https://mcimagetool.com" rel="noopener noreferrer"&gt;&lt;strong&gt;BlockMosaic&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It converts any image into Minecraft blocks right in the browser. No upload, no signup. Here's what went into it and a few things I learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  Everything runs client-side
&lt;/h2&gt;

&lt;p&gt;The whole pipeline is in-browser — your image never touches a server. That's a privacy win and it means zero server cost, but it also forced some interesting constraints.&lt;/p&gt;

&lt;p&gt;The image→blocks conversion runs in a &lt;strong&gt;Web Worker&lt;/strong&gt; so the UI stays responsive, and the heavy code is lazy-loaded with a dynamic import so it never bloats the first paint. The page content itself is server-rendered (static export) for SEO, while the interactive tool hydrates separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Matching colors to blocks
&lt;/h2&gt;

&lt;p&gt;The core is simple: downsample the image to a grid, then match each cell to the nearest block by squared RGB distance. The fun part was the palette.&lt;/p&gt;

&lt;p&gt;I needed accurate average colors for ~160 blocks. Instead of eyeballing them, I extracted the official block textures from the Minecraft client jar and computed the average color of each texture programmatically (averaging only non-transparent pixels, and the first frame of animated textures). Biome-tinted textures like grass are grayscale in the file, so those got a manual override.&lt;/p&gt;

&lt;p&gt;I also added &lt;strong&gt;dithering&lt;/strong&gt; (Floyd–Steinberg and ordered) — when you reduce to a limited block palette, error diffusion makes gradients read way smoother than nearest-match alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exporting builds
&lt;/h2&gt;

&lt;p&gt;Previewing is nice, but the real value is not placing 4,000 blocks by hand. So the tool exports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.litematic&lt;/code&gt;&lt;/strong&gt; for the Litematica mod&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.schem&lt;/code&gt;&lt;/strong&gt; for WorldEdit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.mcfunction&lt;/code&gt;&lt;/strong&gt; as &lt;code&gt;setblock&lt;/code&gt; commands&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both schematic formats are NBT under the hood. There's no NBT library small enough that I wanted to ship, so I wrote a tiny big-endian NBT writer and used the browser's built-in &lt;code&gt;CompressionStream&lt;/code&gt; for gzip. The trickiest bit was Litematica's bit-packed block-state array (palette indices packed across 64-bit longs) — &lt;code&gt;BigInt&lt;/code&gt; made that bearable.&lt;/p&gt;

&lt;p&gt;As a bonus I added a &lt;strong&gt;Litematica → Schematic&lt;/strong&gt; file converter (reads a &lt;code&gt;.litematic&lt;/code&gt;, re-emits a &lt;code&gt;.schem&lt;/code&gt;), which meant writing the NBT &lt;em&gt;reader&lt;/em&gt; too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I'd tell my past self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web Workers + dynamic import&lt;/strong&gt; are the cheap way to keep a heavy client tool from wrecking your load time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;CompressionStream&lt;/code&gt;/&lt;code&gt;DecompressionStream&lt;/code&gt;&lt;/strong&gt; are in every modern browser now — you rarely need a gzip dependency anymore.&lt;/li&gt;
&lt;li&gt;Computing palette colors from real assets beats hand-tuning every time, and it's a 50-line script.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;If you build in Minecraft (or just want to pixelate an image), give it a go:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://mcimagetool.com/pixel-art-generator/" rel="noopener noreferrer"&gt;Minecraft pixel art generator&lt;/a&gt; — image → blocks, with a block shopping list&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mcimagetool.com/image-to-pixel-art/" rel="noopener noreferrer"&gt;Image to pixel art&lt;/a&gt; — generic pixelation, not just Minecraft&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mcimagetool.com/image-to-schematic/" rel="noopener noreferrer"&gt;Image to schematic&lt;/a&gt; — export a buildable blueprint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's free and runs entirely in your browser. I'd love feedback — especially on color accuracy and which export formats you'd want next. What would you build first?&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>minecraft</category>
    </item>
  </channel>
</rss>
