<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[EndureQR Blog]]></title><description><![CDATA[EndureQR Blog]]></description><link>https://endureqr.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 01:10:02 GMT</lastBuildDate><atom:link href="https://endureqr.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How big should a QR code be? The math behind a QR code size calculator]]></title><description><![CDATA[Most printed QR codes that "don't work" aren't broken. They're too small for the distance people scan them from, or too dense for the size they were…]]></description><link>https://endureqr.hashnode.dev/how-big-should-a-qr-code-be-the-math-behind-a-qr-code-size-calculator</link><guid isPermaLink="true">https://endureqr.hashnode.dev/how-big-should-a-qr-code-be-the-math-behind-a-qr-code-size-calculator</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[EndureQR Team]]></dc:creator><pubDate>Thu, 26 Nov 2026 12:13:49 GMT</pubDate><content:encoded><![CDATA[<p>Most printed QR codes that "don't work" aren't broken. They're too small for the distance people scan them from, or too dense for the size they were printed at. I wanted a calculator that answers "how big should this QR code be?" from the actual content, not a generic table. It turned out to be about 20 lines of JavaScript, so here's the math and the code.</p>
<h2>Two limits, and you need the bigger one</h2>
<p>A printed QR code has to satisfy two separate constraints:</p>
<ol>
<li><strong>Distance.</strong> The common rule of thumb is 10:1: the code should be at least a tenth as wide as the distance it's scanned from. A poster read from 2 m needs a code about 20 cm wide.</li>
<li><strong>Density.</strong> A QR code is a grid of <em>modules</em> (the little squares). Each module has to be big enough for a phone camera to resolve. For everyday printing (office printers, textured paper, older phones), about <strong>0.8 mm per module</strong> is a safe floor. With sharp professional printing you can go down to about <strong>0.4 mm</strong>. GS1's minimum for QR codes scanned at retail checkouts is 0.396 mm.</li>
</ol>
<p>The distance rule usually wins for posters. The density rule wins for business cards, labels and anything with a long URL. So the minimum size is simply <code>max(distance / 10, modules × moduleSize)</code>.</p>
<h2>Counting the modules</h2>
<p>The module count depends on the <em>version</em> of the code: version 1 is 21 × 21 modules, and every version adds 4 per side (<code>17 + 4 × version</code>), up to 177 × 177 at version 40. The version is picked by how much data you encode and the error-correction level.</p>
<p>You don't need to compute that yourself. Encode the real content and ask the library. I used <a href="https://www.npmjs.com/package/qrcode-generator">qrcode-generator</a> (MIT, no dependencies):</p>
<pre><code class="language-js">import qrcode from "qrcode-generator";

function moduleCount(text, level = "M") {
  const qr = qrcode(0, level); // 0 = smallest version that fits
  qr.addData(text);
  qr.make();
  return qr.getModuleCount();
}
</code></pre>
<p>Error correction matters here. Most generators default to level M (about 15% of the code can be damaged and still read). If you put a logo in the middle, you need level H (about 30%), and that adds modules.</p>
<h2>The calculator</h2>
<pre><code class="language-js">function minPrintSize(text, distanceMm, { logo = false, pro = false } = {}) {
  const n = moduleCount(text, logo ? "H" : "M");
  const byDistance = distanceMm / 10;        // 10:1 rule
  const byModules = n * (pro ? 0.4 : 0.8);   // smallest readable module
  const width = Math.max(byDistance, byModules, pro ? 10 : 20); // practical floor: 2 cm (1 cm pro)
  return {
    modules: n,
    widthMm: +width.toFixed(1),
    withQuietZoneMm: +((width * (n + 8)) / n).toFixed(1), // 4 blank modules on each side
    px300: Math.ceil((width / 25.4) * 300),               // PNG size at 300 DPI
  };
}

minPrintSize("https://www.example.com", 200);
// { modules: 25, widthMm: 20, withQuietZoneMm: 26.4, px300: 237 }
</code></pre>
<p>Two details people often miss:</p>
<ul>
<li><strong>The quiet zone.</strong> The QR spec asks for a blank margin of 4 modules on every side. It's part of the code, so the printed area is <code>width × (n + 8) / n</code>. Designers trim it to fit a layout, and that alone breaks a lot of codes.</li>
<li><strong>Pixels.</strong> If you export a PNG rather than SVG or PDF, you want 300 pixels per inch of printed width. Vector formats skip the question entirely.</li>
</ul>
<h2>What the numbers look like</h2>
<p>I ran the function over some typical content, for a business card scanned from 20 cm:</p>
<table>
<thead>
<tr>
<th>Content</th>
<th>Characters</th>
<th>Modules (M)</th>
<th>Modules (H, logo)</th>
<th>Min width</th>
<th>With logo</th>
</tr>
</thead>
<tbody><tr>
<td>Homepage URL</td>
<td>23</td>
<td>25</td>
<td>29</td>
<td>2.0 cm</td>
<td>2.3 cm</td>
</tr>
<tr>
<td>WiFi login</td>
<td>38</td>
<td>29</td>
<td>37</td>
<td>2.3 cm</td>
<td>3.0 cm</td>
</tr>
<tr>
<td>Page URL with a path</td>
<td>44</td>
<td>33</td>
<td>37</td>
<td>2.6 cm</td>
<td>3.0 cm</td>
</tr>
<tr>
<td>URL with UTM tags</td>
<td>101</td>
<td>41</td>
<td>57</td>
<td>3.3 cm</td>
<td>4.6 cm</td>
</tr>
<tr>
<td>vCard with 5 fields</td>
<td>128</td>
<td>49</td>
<td>61</td>
<td>3.9 cm</td>
<td>4.9 cm</td>
</tr>
</tbody></table>
<p>At 20 cm, the distance rule only asks for 2 cm, so everything above the first row is set by density. Tracking tags plus a logo take a page URL from 2.6 cm to 4.6 cm. <strong>The cheapest fix for a code that has to be small is shorter content</strong>: drop UTM parameters, use a short link, or link to a page instead of encoding a full contact card.</p>
<p>For a poster at 2 m, the same homepage URL needs 20 cm (2,363 px at 300 DPI). There the module count barely matters.</p>
<h2>Caveats</h2>
<p>These are rules of thumb, not physics. Lighting, glossy laminate, curved surfaces and scanning at an angle all push the real minimum up. Always print one copy at the final size and scan it with an iPhone and an Android phone from where people will actually stand.</p>
<h2>Try it</h2>
<p>I put this into a free browser tool: paste your link, pick a distance, and it shows the minimum size, module size and pixels: <a href="https://endureqr.com/qr-code-size-calculator">QR code size calculator</a>. If you want the longer explanation with sources, there's a guide to <a href="https://endureqr.com/guides/qr-code-size-for-printing">minimum QR code sizes for printing</a>.</p>
<p>If you've had a printed code fail on you, I'd like to hear what the cause turned out to be.</p>
<p><em>Disclosure: I build EndureQR, the site the calculator is on. The code above is all you need to run it yourself.</em></p>
]]></content:encoded></item><item><title><![CDATA[I decoded "free" QR codes from 20 generators with Playwright and jsQR. Here's what was inside]]></title><description><![CDATA[A QR code is just data. You can't tell by looking at one whether it holds your URL or somebody else's short link, and that difference decides whether a…]]></description><link>https://endureqr.hashnode.dev/i-decoded-free-qr-codes-from-20-generators-with-playwright-and-jsqr-here-s-what-was-inside</link><guid isPermaLink="true">https://endureqr.hashnode.dev/i-decoded-free-qr-codes-from-20-generators-with-playwright-and-jsqr-here-s-what-was-inside</guid><category><![CDATA[webdev]]></category><category><![CDATA[Testing]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[playwright]]></category><dc:creator><![CDATA[EndureQR Team]]></dc:creator><pubDate>Sun, 22 Nov 2026 20:37:32 GMT</pubDate><content:encoded><![CDATA[<p>A QR code is just data. You can't tell by looking at one whether it holds your URL or somebody else's short link, and that difference decides whether a printed code keeps working.</p>
<p>So we tested it. We opened 20 popular "free QR code generator" sites in a clean headless browser, made a code for a test URL on each one, downloaded the image and decoded it. Here's how, and what came back.</p>
<p><em>Disclosure: we build EndureQR, a QR code tool, so we have a stake in this. That's why the method is published in full below, and it's easy to repeat.</em></p>
<h2>The question</h2>
<p>When you make a QR code for a website link with a generator's default free flow, does the image contain:</p>
<ul>
<li><strong>your URL</strong> (a static code: it works as long as your page exists), or</li>
<li><strong>the vendor's short link</strong> (a dynamic code: every scan goes through their server, and it stops when they switch the link off)?</li>
</ul>
<h2>The setup</h2>
<ul>
<li>Playwright with its bundled headless Chromium, a fresh profile per site: no cookies, no login.</li>
<li>Each site left on its <strong>default settings</strong>.</li>
<li>Test URL: <code>https://example.com/study-&lt;site&gt;</code>, so every payload is traceable.</li>
<li>We never entered an email address, never created an account, and stopped at any sign-up wall.</li>
</ul>
<h2>Decoding the downloads</h2>
<p>Downloaded codes come in all shapes: PNGs with no margin, rounded "dot" modules, gradients. jsQR wants clean RGBA pixels, so we ran each image through <code>sharp</code> and tried a few variants until one decoded:</p>
<pre><code class="language-js">import sharp from "sharp";
import jsQR from "jsqr";

// sharp may hand back 1 (grey), 3 or 4 channels; jsQR always wants RGBA
function toRGBA(data, { width, height, channels }) {
  const out = new Uint8ClampedArray(width * height * 4);
  for (let i = 0, j = 0; j &lt; out.length; i += channels, j += 4) {
    const grey = channels &lt; 3;
    out[j] = data[i];
    out[j + 1] = grey ? data[i] : data[i + 1];
    out[j + 2] = grey ? data[i] : data[i + 2];
    out[j + 3] = 255;
  }
  return out;
}

export async function decode(file) {
  const variants = [
    (img) =&gt; img,                                            // as downloaded
    (img) =&gt; img.extend({ top: 40, bottom: 40, left: 40, right: 40, background: "#fff" }), // add a quiet zone
    (img) =&gt; img.greyscale().threshold(160),                 // hard black/white
    (img) =&gt; img.greyscale().blur(2.5).threshold(245),       // merge "dot" modules
  ];
  for (const width of [null, 400, 800]) {
    for (const v of variants) {
      let img = sharp(file, { density: 300 }).flatten({ background: "#fff" });
      if (width) img = img.resize({ width, kernel: "nearest" });
      const { data, info } = await v(img).raw().toBuffer({ resolveWithObject: true });
      const res = jsQR(toRGBA(data, info), info.width, info.height, { inversionAttempts: "attemptBoth" });
      if (res?.data) return res.data;
    }
  }
  return null;
}
</code></pre>
<p>Two lessons from this part:</p>
<ol>
<li><strong>Add a quiet zone before decoding.</strong> Several generators export the code with no margin at all, and jsQR (like phone cameras) struggles without one.</li>
<li><strong>Blur, then threshold, for dotted designs.</strong> Round "dot" modules don't read as squares; a small blur followed by a high threshold joins them back into modules. Only one site needed this.</li>
</ol>
<h2>Following the short links</h2>
<p>When a payload was a vendor short link, we checked where it went without following it:</p>
<pre><code class="language-bash">curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" https://qrs.ly/xxxxxxx
# 302 https://example.com/study-qrstuff
</code></pre>
<p>All three short links redirected to our test pages on the day. Whether they keep doing so is up to the vendor.</p>
<h2>What came back</h2>
<table>
<thead>
<tr>
<th>Result</th>
<th>Count</th>
<th>Sites</th>
</tr>
</thead>
<tbody><tr>
<td>Direct: the image held our URL</td>
<td>6</td>
<td>QRCode Monkey, Scanova, goQR.me, Hovercode, The QR Code Generator (small watermark), QRCodeChimp (via right-click "Save as")</td>
</tr>
<tr>
<td>Vendor short link, no account needed</td>
<td>3</td>
<td>QRStuff (default works for 7 days), Unitag (100 scans max), ME-QR (ads may show after 10 scans)</td>
</tr>
<tr>
<td>Account or email required before download</td>
<td>11</td>
<td>including QR Code Generator, QRFY, Uniqode, Flowcode, Bitly, Canva, Adobe Express</td>
</tr>
</tbody></table>
<p>Two things surprised us:</p>
<ul>
<li><strong>Defaults matter more than features.</strong> QRStuff makes a dynamic code by default, and the notice next to its Download button says it "works for 7 days, or 30 days with a free account" (to its credit, it says so clearly and offers a Static switch). QR Code Generator has "Scan tracking" on by default, which puts the download behind a sign-up; switch it off and you get a direct code with no account.</li>
<li><strong>Previews aren't proof.</strong> Several sign-up sites show a code on the page that decodes to your URL. That's a preview, not necessarily the file a registered user gets, so we didn't count any of them as direct.</li>
</ul>
<p>The full table, with each company's own words on what happens when a trial or plan ends (10 of the 17 services offering dynamic codes say some codes stop, pause or change), is here: <strong><a href="https://endureqr.com/guides/free-qr-code-generators-tested">We made a free QR code on 20 generators</a></strong>.</p>
<h2>Check a code yourself in 30 seconds</h2>
<p>You don't need any of the code above to check one QR code. Point your phone camera at it and read the address it shows <em>before</em> tapping. If it's your own domain, it's direct. If it's a short domain you don't own, the code depends on that company.</p>
<p>If you build QR features into an app, the takeaway is simple: <strong>for anything printed, encode the destination directly</strong> unless you really need editing or analytics, and if you do use a redirect, make sure you control it.</p>
<h2>Limits</h2>
<p>One run per site, one desktop browser, one location, on 21 November 2026. Sites change and A/B test their defaults, so treat these results as a snapshot. We couldn't see what registered users get on the 11 sign-up sites.</p>
]]></content:encoded></item></channel></rss>