<?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: Allan Hall</title>
    <description>The latest articles on DEV Community by Allan Hall (@allanhall_plasticcard).</description>
    <link>https://dev.to/allanhall_plasticcard</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%2F4236191%2F9b759698-66c2-4932-ad66-45c4a7775fab.png</url>
      <title>DEV Community: Allan Hall</title>
      <link>https://dev.to/allanhall_plasticcard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/allanhall_plasticcard"/>
    <language>en</language>
    <item>
      <title>Card numbers for loyalty and gift cards: Luhn check digits, sequential vs random, and the CSV the printer needs</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Mon, 16 Nov 2026 19:52:08 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/card-numbers-for-loyalty-and-gift-cards-luhn-check-digits-sequential-vs-random-and-the-csv-the-3gng</link>
      <guid>https://dev.to/allanhall_plasticcard/card-numbers-for-loyalty-and-gift-cards-luhn-check-digits-sequential-vs-random-and-the-csv-the-3gng</guid>
      <description>&lt;p&gt;If you are building a loyalty, gift or membership card system, you will have to decide what number goes on each card before anything is printed. That number ends up in your database, in a barcode, maybe on a magnetic stripe, and on the face of the card where staff type it in by hand. A few choices made early save a lot of trouble later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sequential or random?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Sequential&lt;/strong&gt; numbers (000001, 000002, ...) are easy to print, easy to check for gaps, and fine for membership cards where the number is only an identifier and the card has no value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random&lt;/strong&gt; numbers are better when the card carries value (gift cards, prepaid balances, loyalty points that can be redeemed). If numbers are sequential, someone holding card 000500 can guess that 000501 exists. Use a cryptographically secure generator, not &lt;code&gt;Math.random()&lt;/code&gt; or Python's &lt;code&gt;random&lt;/code&gt; module.&lt;/p&gt;

&lt;p&gt;A common middle ground is a short fixed prefix for the programme, a random body, and a check digit at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add a check digit
&lt;/h2&gt;

&lt;p&gt;Staff will key numbers in by hand at a till or front desk. A check digit catches most typing mistakes before they hit your database. The usual choice is the Luhn algorithm (the same one used on payment card numbers). It catches every single-digit error and most swaps of two adjacent digits (09 and 90 is the one swap it misses).&lt;/p&gt;

&lt;p&gt;Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;luhn_check_digit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;reversed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# these get doubled once the check digit is appended&lt;/span&gt;
            &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;luhn_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;luhn_check_digit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;luhn_check_digit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"7992739871"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"3"&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;luhn_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"79927398713"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;luhnCheckDigit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;luhnCheckDigit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"7992739871"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// "3"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generating a random 16-digit number with a prefix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;random_card_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;body_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0123456789"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body_len&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;luhn_check_digit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check each new number against the ones you already issued before you add it to the print file. With 11 random digits a collision is rare, but it only takes one duplicate to cause a support ticket.&lt;/p&gt;

&lt;p&gt;Don't start a loyalty number with a prefix that looks like a real payment card range (4 or 5 followed by 15 digits is the obvious one). Some POS systems and card readers will try to treat it as a bank card.&lt;/p&gt;

&lt;h2&gt;
  
  
  Length and readability
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;12 to 16 digits is enough for most programmes and still fits one line on a CR80 card.&lt;/li&gt;
&lt;li&gt;Print it in groups of four (&lt;code&gt;6001 5966 4683 4484&lt;/code&gt;) so people can read it back. Store it without spaces.&lt;/li&gt;
&lt;li&gt;Avoid letters if staff key it in. If you need letters, drop the ones that look like digits (O, I, L, S, B).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Barcodes
&lt;/h2&gt;

&lt;p&gt;If the number is also printed as a barcode, keep the barcode content identical to the printed number, without spaces. Code 128 is the usual choice for variable numbers on cards because it is compact and handles any length. EAN-13 only works if your number is exactly 13 digits and follows its own check digit rule, which is different from Luhn. If you want a QR code instead, encode the number or a URL with the number in the path.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data file for the printer
&lt;/h2&gt;

&lt;p&gt;The printer needs one row per card, in the order the cards should be printed. A plain CSV is the safest format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sequence,card_number,barcode
1,6001596646834484,6001596646834484
2,6001207718395525,6001207718395525
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Things that go wrong:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Leading zeros vanish&lt;/strong&gt; if someone opens the CSV in Excel and saves it again. Send the file as generated, or quote the fields.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long numbers turn into scientific notation&lt;/strong&gt; in spreadsheets (&lt;code&gt;6.00159E+15&lt;/code&gt;). Same fix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duplicates.&lt;/strong&gt; Run a uniqueness check on the file before you send it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No sequence column.&lt;/strong&gt; Without one, nobody can easily tell if a card is missing from a pack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ask the printer to send back a proof of the first few and last few cards, and check those numbers against your file.&lt;/p&gt;

&lt;p&gt;I work at &lt;a href="https://plasticcard.nz/" rel="noopener noreferrer"&gt;PlasticCard.nz&lt;/a&gt;, a plastic card supplier in New Zealand. We have longer notes on &lt;a href="https://plasticcard.nz/barcode-numbering-magnetic-stripe-guide/" rel="noopener noreferrer"&gt;barcodes, numbering and magnetic stripes&lt;/a&gt; and on &lt;a href="https://plasticcard.nz/variable-data-card-printing/" rel="noopener noreferrer"&gt;variable data printing&lt;/a&gt;, and these questions come up most with &lt;a href="https://plasticcard.nz/loyalty-gift-cards/" rel="noopener noreferrer"&gt;loyalty and gift cards&lt;/a&gt;. Corrections from people who run card programmes at scale are welcome in the comments.&lt;/p&gt;

</description>
      <category>printing</category>
      <category>python</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>NFC cards for developers: NTAG213 vs 215 vs 216, NDEF URL records, and what to send the printer</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Mon, 16 Nov 2026 01:10:47 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/nfc-cards-for-developers-ntag213-vs-215-vs-216-ndef-url-records-and-what-to-send-the-printer-4h0j</link>
      <guid>https://dev.to/allanhall_plasticcard/nfc-cards-for-developers-ntag213-vs-215-vs-216-ndef-url-records-and-what-to-send-the-printer-4h0j</guid>
      <description>&lt;p&gt;If you are building a tap-to-open feature (a digital business card, a membership check-in, a link on a loyalty card), the chip choice and the encoded record matter more than the card artwork. These are the questions I see most often from developers ordering their first batch of NFC cards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which chip?
&lt;/h2&gt;

&lt;p&gt;For "tap a phone, open a URL", the common choice is an NXP NTAG21x chip. They are ISO/IEC 14443-A, run at 13.56 MHz, and are NFC Forum Type 2 tags, so both iPhones and Android phones read them without an app.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Chip&lt;/th&gt;
&lt;th&gt;User memory&lt;/th&gt;
&lt;th&gt;Practical use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;NTAG213&lt;/td&gt;
&lt;td&gt;144 bytes&lt;/td&gt;
&lt;td&gt;One URL, comfortably&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NTAG215&lt;/td&gt;
&lt;td&gt;504 bytes&lt;/td&gt;
&lt;td&gt;Longer URLs, a vCard with a few fields&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NTAG216&lt;/td&gt;
&lt;td&gt;888 bytes&lt;/td&gt;
&lt;td&gt;Full vCard, several records&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A typical profile URL fits in NTAG213 with plenty of room. Only move up if you want to store a vCard on the chip itself instead of linking to one.&lt;/p&gt;

&lt;p&gt;Two things are often confused with these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;125 kHz proximity cards&lt;/strong&gt; (EM4100 type) only hold a fixed ID number. Phones can't read them. They are for door readers that already expect them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MIFARE Classic 1K&lt;/strong&gt; is common in access and transit systems. Many phones can read it, but it is not the chip to pick if all you need is a URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are matching an existing door or POS reader, ask for the reader's spec before you choose. The phone use case and the reader use case often need different chips.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a URL record looks like
&lt;/h2&gt;

&lt;p&gt;A URL on an NTAG is an NDEF message with one URI record. The record saves space by replacing common prefixes with a one-byte code:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Prefix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0x01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;http://www.&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0x02&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://www.&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0x03&lt;/td&gt;
&lt;td&gt;&lt;code&gt;http://&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0x04&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here is a small Python function that builds the bytes, so you can check how much memory a URL needs before you order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;PREFIXES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"https://www."&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"http://www."&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"https://"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x04&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"http://"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;0x03&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ndef_uri_record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;PREFIXES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"use a long record or a shorter URL"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# MB=1, ME=1, SR=1, TNF=0x01 (well-known) -&amp;gt; 0xD1; type "U"&lt;/span&gt;
    &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mh"&gt;0xD1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"U"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;
    &lt;span class="c1"&gt;# Type 2 tags wrap the message in an NDEF TLV, then a terminator&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mh"&gt;0x03&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"\xFE"&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ndef_uri_record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://example.com/m/000123"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"bytes"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 28 bytes: fits NTAG213 easily&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole message the chip needs. Short, unique paths (&lt;code&gt;/m/000123&lt;/code&gt;) are better than long query strings: they fit any chip, and you can change where they redirect later without re-encoding cards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing in the browser
&lt;/h2&gt;

&lt;p&gt;On Android Chrome you can read and write tags from a web page with Web NFC (HTTPS only, user gesture required):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;writeTag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ndef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NDEFReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ndef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;recordType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;readTag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ndef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NDEFReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ndef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;ndef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onreading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;serialNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serialNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is useful for checking sample cards. iOS Safari does not support Web NFC, but iPhones still open a URL record when the card is tapped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locking and passwords
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lock bits&lt;/strong&gt; make the memory read-only permanently. Lock production cards so nobody can rewrite them with a free app, but only after you have tested a sample.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NTAG21x password protection&lt;/strong&gt; is a 32-bit password that blocks writes (and optionally reads). It stops casual tampering. It is not strong security, so don't put anything sensitive on the chip.&lt;/li&gt;
&lt;li&gt;Every NTAG has a &lt;strong&gt;7-byte UID&lt;/strong&gt;. If your system needs to know which card was tapped, put an ID in the URL path rather than relying on reading the UID from a web page, because a phone opening a URL doesn't send the UID.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The data file for the printer
&lt;/h2&gt;

&lt;p&gt;If each card gets a different URL, the printer needs a file that matches the encoding to the printed number. A plain CSV works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;card_number,url
000123,https://example.com/m/000123
000124,https://example.com/m/000124
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep numbers as text so leading zeros survive (Excel drops them if you open and resave the file). Ask whether they can return a UID list after encoding, so you can map each chip to a record if you ever need it. PlasticCard.nz has a longer write-up on &lt;a href="https://plasticcard.nz/rfid-nfc-cards-guide/" rel="noopener noreferrer"&gt;RFID and NFC card options&lt;/a&gt; and on &lt;a href="https://plasticcard.nz/variable-data-card-printing/" rel="noopener noreferrer"&gt;variable data printing&lt;/a&gt; if you want to read about chip choice and numbering from the print side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you order
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Check the URL length with the function above.&lt;/li&gt;
&lt;li&gt;Test one sample on both an iPhone and an Android phone.&lt;/li&gt;
&lt;li&gt;Keep the antenna area in mind: metallic inks and full metal finishes can reduce read range, so ask before choosing them.&lt;/li&gt;
&lt;li&gt;Lock the chip only after testing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I work at &lt;a href="https://plasticcard.nz/" rel="noopener noreferrer"&gt;PlasticCard.nz&lt;/a&gt;, a plastic card supplier in New Zealand, and these come up whenever someone orders &lt;a href="https://plasticcard.nz/nfc-digital-business-cards/" rel="noopener noreferrer"&gt;NFC digital business cards&lt;/a&gt;. Corrections from people who encode these at scale are welcome in the comments.&lt;/p&gt;

</description>
      <category>nfc</category>
      <category>printing</category>
      <category>javascript</category>
      <category>python</category>
    </item>
    <item>
      <title>Magnetic stripe cards for developers: tracks, HiCo vs LoCo, and the data file the printer needs</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Fri, 13 Nov 2026 19:52:57 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/magnetic-stripe-cards-for-developers-tracks-hico-vs-loco-and-the-data-file-the-printer-needs-2n9l</link>
      <guid>https://dev.to/allanhall_plasticcard/magnetic-stripe-cards-for-developers-tracks-hico-vs-loco-and-the-data-file-the-printer-needs-2n9l</guid>
      <description>&lt;p&gt;If your app has to issue swipe cards for an existing reader (a gym door, a loyalty terminal, a library system), most of the work is not the artwork. It is getting the encoded data right so the reader accepts it on the first test card. These are the parts I see developers ask about most.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three tracks
&lt;/h2&gt;

&lt;p&gt;A standard ID-1 card stripe (the same 85.60 x 53.98 mm size as a bank card) has up to three tracks, defined in ISO/IEC 7811 and 7813:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Track&lt;/th&gt;
&lt;th&gt;Density&lt;/th&gt;
&lt;th&gt;Character set&lt;/th&gt;
&lt;th&gt;Max characters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;210 bpi&lt;/td&gt;
&lt;td&gt;Alphanumeric (6-bit)&lt;/td&gt;
&lt;td&gt;79&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;75 bpi&lt;/td&gt;
&lt;td&gt;Numeric (4-bit)&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;210 bpi&lt;/td&gt;
&lt;td&gt;Numeric (4-bit)&lt;/td&gt;
&lt;td&gt;107&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most membership, loyalty and access systems only read track 2. Check what your reader actually reads before you plan data for all three.&lt;/p&gt;

&lt;p&gt;Each track starts and ends with sentinels. On track 1 that is % at the start and ? at the end. On track 2 it is ; and ?. Fields inside a track are separated by ^ on track 1 and = on track 2. An LRC check character follows the end sentinel. Encoding software usually adds the sentinels and LRC for you, so ask whether your data file should include them or not. Sending them twice is a common cause of failed test cards.&lt;/p&gt;

&lt;p&gt;A typical track 2 string for a member card might be just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;;1000234567?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  HiCo or LoCo
&lt;/h2&gt;

&lt;p&gt;This is about how hard the stripe is to erase, not how much data it holds.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LoCo&lt;/strong&gt; (low coercivity, about 300 Oe) is cheaper and fine for short-life cards such as hotel keys, but a phone magnet or a bag clasp can wipe it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HiCo&lt;/strong&gt; (high coercivity, about 2750 to 4000 Oe) resists accidental erasing and suits cards people carry for months or years.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most readers read both. The encoder is the limit: a LoCo-only encoder cannot write HiCo stripes. If the system provider does not specify, HiCo is the safer choice for anything long-lived.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data file
&lt;/h2&gt;

&lt;p&gt;Treat the encoding file as production data, not a spreadsheet someone tidies by hand.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep one row per card and one clearly named column per field (&lt;code&gt;printed_number&lt;/code&gt;, &lt;code&gt;track2&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Store numbers as text. Excel will strip leading zeros from &lt;code&gt;0012345&lt;/code&gt; and turn long numbers into &lt;code&gt;1.23E+15&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Generate the printed number, any barcode value and the track data from the same source record so they always match.&lt;/li&gt;
&lt;li&gt;Check for duplicates and blank rows before you send it.&lt;/li&gt;
&lt;li&gt;Agree with the printer whether the file order is the card order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a longer checklist for numbered and encoded runs on the &lt;a href="https://plasticcard.nz/variable-data-card-printing/" rel="noopener noreferrer"&gt;variable data card printing page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Artwork around the stripe
&lt;/h2&gt;

&lt;p&gt;The stripe sits on the back of the card along the long top edge, as a band roughly 12.7 mm tall for a three-track stripe. Keep text, signatures and barcodes out of that band, and leave a little clearance either side. If you also print a barcode or QR code, keep it on a plain high-contrast background away from the stripe.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://plasticcard.nz/barcode-numbering-magnetic-stripe-guide/" rel="noopener noreferrer"&gt;barcode, numbering and magnetic stripe guide&lt;/a&gt; covers when a printed number, barcode or stripe is the better fit, and the &lt;a href="https://plasticcard.nz/tools/card-artwork-checker/" rel="noopener noreferrer"&gt;free card artwork checker&lt;/a&gt; lets you check bleed and safe margins on your file before it goes to print.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test before the full run
&lt;/h2&gt;

&lt;p&gt;Ask for a small number of encoded sample cards and swipe them on the real reader, with the real software, before approving the run. Check:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The reader accepts the card at all (track and coercivity).&lt;/li&gt;
&lt;li&gt;The number the software shows matches the number printed on the card.&lt;/li&gt;
&lt;li&gt;Leading zeros survived.&lt;/li&gt;
&lt;li&gt;A second card from a different row of the file also reads correctly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last check catches a shifted or sorted file, which is easy to miss when you only test the first row.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Allan Hall at &lt;a href="https://plasticcard.nz/" rel="noopener noreferrer"&gt;PlasticCard.nz&lt;/a&gt;, a New Zealand plastic card supplier. Corrections and questions are welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>printing</category>
      <category>hardware</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How big should a QR code be when printed? Minimum size, quiet zone and error correction for print</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Fri, 13 Nov 2026 02:27:57 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/how-big-should-a-qr-code-be-when-printed-minimum-size-quiet-zone-and-error-correction-for-print-29li</link>
      <guid>https://dev.to/allanhall_plasticcard/how-big-should-a-qr-code-be-when-printed-minimum-size-quiet-zone-and-error-correction-for-print-29li</guid>
      <description>&lt;p&gt;A QR code that looks sharp on a phone can fail in print: the modules are too small for the scanner, the quiet zone got cropped, or contrast disappeared on dark or glossy stock. This note is for developers generating codes for cards, labels or flyers.&lt;/p&gt;

&lt;p&gt;The figures below come from DENSO WAVE, the inventor of QR Code, whose public documentation matches the model in ISO/IEC 18004 (first published as an ISO standard in 2000; current edition 2024). I am not quoting unpublished tables from the standard itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size is module size times module count
&lt;/h2&gt;

&lt;p&gt;A QR Code is a grid of square modules. Once you know the version, printed size is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printed size = (modules + 2 × quiet-zone modules) × module size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;DENSO WAVE's outline of the specification gives the grid sizes: Version 1 is 21 × 21 modules, growing by four modules per side up to Version 40 at 177 × 177. Version &lt;em&gt;V&lt;/em&gt; is &lt;code&gt;21 + 4 × (V − 1)&lt;/code&gt; modules on a side. The payload, not a style option, usually picks the version. A short HTTPS URL often fits in Version 2 or 3; a long tracking URL, vCard or Wi-Fi string can jump several versions. Prefer a short, stable URL if the print area is tight.&lt;/p&gt;

&lt;h2&gt;
  
  
  The quiet zone is four modules, on every side
&lt;/h2&gt;

&lt;p&gt;DENSO WAVE is direct: "QR Code requires a four-module wide margin at all sides of a symbol." That is a clear area with nothing printed in it — no logo, crop mark or background pattern. Those four modules on each side add eight modules to the width, so a Version 3 symbol (29 modules of data) occupies a 37-module square. If a layout tool or a &lt;code&gt;margin: 0&lt;/code&gt; export trims that margin, readers may fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  A worked example from the official docs
&lt;/h2&gt;

&lt;p&gt;DENSO WAVE encodes 50 alphanumeric characters at error-correction level M. That requires Version 3 (29 modules); Version 2 at level M only holds 38 alphanumeric characters. They then print on a 400 dpi printer with a 4-dot module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module size = 25.4 mm/inch ÷ 400 dpi × 4 dots/module = 0.254 mm/module
data area  = 29 × 0.254 mm = 7.366 mm
full area  = 7.366 + (0.254 × 8) = 9.398 mm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reserved square, including the quiet zone, is 9.398 mm on a side. That is a printer-stable size for a machine that can resolve 0.254 mm modules — not, on its own, a comfortable size for a phone camera.&lt;/p&gt;

&lt;h2&gt;
  
  
  Module size is limited by the printer and the scanner
&lt;/h2&gt;

&lt;p&gt;DENSO WAVE recommends that each module be made of &lt;strong&gt;four or more printer dots&lt;/strong&gt;, so the cell stays square when the head or paper feed varies. At 600 dpi, a 4-dot module is 0.17 mm; at 360 dpi it is 0.28 mm; at 300 dpi thermal, 0.33 mm; at 200 dpi thermal, 0.50 mm. A Version 1 symbol at that 600 dpi size is 21 × 0.17 mm = 3.57 mm before the quiet zone — a printer floor, not a target for a handheld camera.&lt;/p&gt;

&lt;p&gt;Each scanner also has its own readable module-size limit. DENSO WAVE lists industrial "standard type" readers around 0.25 mm, and camera-type readers and phone decode software as "variable according to lens." Size the symbol for the &lt;strong&gt;scanner you actually have&lt;/strong&gt;, and print it as large as the layout reasonably allows.&lt;/p&gt;

&lt;p&gt;For phone scanning, start from the space you can give the code, then test. If you reserve a 22 mm square, quiet zone included, for a Version 3 symbol (37 modules), each module is &lt;code&gt;22 / 37 ≈ 0.59 mm&lt;/code&gt; — well above the 4-dot printer floor. A common print-industry rule of thumb is to make the symbol about one tenth of the intended scan distance — a starting point to test, not a figure from ISO/IEC 18004.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error correction changes the version, not just robustness
&lt;/h2&gt;

&lt;p&gt;QR Code uses Reed-Solomon error correction. DENSO WAVE states the approximate proportion of codewords that can be restored, and notes that level M is the one most frequently selected: &lt;strong&gt;L ≈ 7%&lt;/strong&gt; (clean environment, large amount of data), &lt;strong&gt;M ≈ 15%&lt;/strong&gt; (the usual default), &lt;strong&gt;Q ≈ 25%&lt;/strong&gt; and &lt;strong&gt;H ≈ 30%&lt;/strong&gt; (dirtier environments).&lt;/p&gt;

&lt;p&gt;Raising the level does not protect a code that is printed too small. It consumes capacity, which can bump the symbol to a higher version and shrink every module if you keep the same printed square. For a card or label that will be handled or scuffed, Q or H is reasonable if the modules stay large enough. For a short URL on a clean flyer, M is the documented default. If you punch a logo out of the centre, keep the finder and alignment patterns clear, keep the quiet zone intact, and test the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contrast, finish and file format
&lt;/h2&gt;

&lt;p&gt;Readers distinguish modules by the difference in reflected light between dark and light cells. The reliable default is &lt;strong&gt;dark modules on a light, opaque background&lt;/strong&gt;. DENSO WAVE notes that a symbol on a transparent bag needs a white background behind it, and that a glistening surface can interfere with reading. Low-contrast palettes, inverted (light-on-dark) codes, busy backgrounds and laminate glare are the usual failures; on dark or metallic stock, put the code in a solid light patch that includes the quiet zone.&lt;/p&gt;

&lt;p&gt;Export &lt;strong&gt;SVG or PDF&lt;/strong&gt; when you can. Vector modules stay sharp at any print size, and a 4-module border in the file is a 4-module border on paper. If you must ship a PNG, treat &lt;code&gt;scale&lt;/code&gt; or &lt;code&gt;width&lt;/code&gt; as pixels per module, not as "the size of the code." Give the raster several pixels per module, then size that bitmap to the physical millimetre size at 300 or 600 DPI. Do not stretch a 128-pixel PNG across a 30 mm square, and do not drop the quiet zone to zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate it with the right margin and ECC
&lt;/h2&gt;

&lt;p&gt;Python, with &lt;a href="https://pypi.org/project/segno/" rel="noopener noreferrer"&gt;segno&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;segno&lt;/span&gt;

&lt;span class="n"&gt;qr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;segno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://example.com/event"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"M"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# border is the quiet zone in modules; 4 is the required margin&lt;/span&gt;
&lt;span class="n"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"qr.svg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# scale is pixels per module in a raster export, not millimetres&lt;/span&gt;
&lt;span class="n"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"qr.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Node.js, with the &lt;a href="https://www.npmjs.com/package/qrcode" rel="noopener noreferrer"&gt;&lt;code&gt;qrcode&lt;/code&gt;&lt;/a&gt; package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;QRCode&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"qrcode"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/event"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;QRCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"qr.svg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"svg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;errorCorrectionLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"M"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// quiet zone in modules&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;QRCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"qr.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;errorCorrectionLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"M"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// output pixels; prefer a multiple of (modules + 2×margin)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A browser &lt;a href="https://plasticcard.nz/tools/qr-code-generator/" rel="noopener noreferrer"&gt;QR code generator&lt;/a&gt; is useful when you want to inspect the version, the quiet zone and a vector download before the symbol goes into a print file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test on the real object
&lt;/h2&gt;

&lt;p&gt;Preview at 100% zoom is not a test. Print at the final size on the final stock, including any laminate, and scan with two phones in ordinary light at the real reading distance. If the code is on a card, keep it inside the safe area so trim cannot eat the quiet zone; a &lt;a href="https://plasticcard.nz/tools/card-artwork-checker/" rel="noopener noreferrer"&gt;CR80 artwork checker&lt;/a&gt; will show that overlay on an ID-1 / CR80 card.&lt;/p&gt;

&lt;p&gt;If a test scan is flaky, enlarge the modules, restore the four-module quiet zone, increase contrast, shorten the URL, then raise the error-correction level if the surface will take damage.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Printed size = &lt;code&gt;(modules + 8) × module size&lt;/code&gt;. Version 1 is 21 × 21; each version adds four modules per side. Keep a &lt;strong&gt;four-module quiet zone&lt;/strong&gt; on every side.&lt;/li&gt;
&lt;li&gt;Four or more printer dots per module is the official floor; 0.17 mm at 600 dpi is a printer minimum, not a phone-scanning size.&lt;/li&gt;
&lt;li&gt;Default to error-correction &lt;strong&gt;M&lt;/strong&gt;. Dark on a light, matte, opaque patch. Prefer SVG or PDF, and test a real print with more than one phone.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>python</category>
      <category>design</category>
    </item>
    <item>
      <title>CR80 card size in pixels, mm and inches: a developer's cheat sheet</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Thu, 12 Nov 2026 23:11:53 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/cr80-card-size-in-pixels-mm-and-inches-a-developers-cheat-sheet-5eeb</link>
      <guid>https://dev.to/allanhall_plasticcard/cr80-card-size-in-pixels-mm-and-inches-a-developers-cheat-sheet-5eeb</guid>
      <description>&lt;p&gt;Sooner or later someone asks you to build a membership card preview, a gift card mockup or a "download your staff ID" feature. The first question is always the same: how big is a card, really? The answer is more precise than "about 86 by 54", and getting it slightly wrong is how you end up with artwork that gets cropped at the printer.&lt;/p&gt;

&lt;p&gt;This is the reference I wish I'd had: the numbers, the pixel maths, and copy-paste snippets.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;A standard plastic card (bank card, loyalty card, ID badge) is the &lt;strong&gt;ID-1&lt;/strong&gt; format from ISO/IEC 7810. The printing industry calls it &lt;strong&gt;CR80&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Millimetres&lt;/th&gt;
&lt;th&gt;Inches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Width&lt;/td&gt;
&lt;td&gt;85.60 mm&lt;/td&gt;
&lt;td&gt;3.370 in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Height&lt;/td&gt;
&lt;td&gt;53.98 mm&lt;/td&gt;
&lt;td&gt;2.125 in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Corner radius&lt;/td&gt;
&lt;td&gt;~3.18 mm&lt;/td&gt;
&lt;td&gt;0.125 in (1/8")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thickness (typical)&lt;/td&gt;
&lt;td&gt;0.76 mm&lt;/td&gt;
&lt;td&gt;0.030 in (30 mil)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Aspect ratio:&lt;/strong&gt; 85.60 / 53.98 ≈ &lt;strong&gt;1.586 : 1&lt;/strong&gt; (or 0.6306 the other way round). That's close to the golden ratio (1.618) but not equal to it, so don't reach for &lt;code&gt;1.618&lt;/code&gt; as a shortcut.&lt;/p&gt;

&lt;p&gt;You'll see 3.375 in quoted for the width in some printer drivers and US templates. That's 85.725 mm, a rounded imperial figure, not the ISO value. The difference is about 0.1 mm, which doesn't matter for a screen mockup, but use 85.60 mm when you're generating print files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bleed and safe area
&lt;/h2&gt;

&lt;p&gt;Printed cards are cut from larger sheets, and the cut can drift slightly. Two margins handle that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bleed:&lt;/strong&gt; background colour and images extend past the trim line, commonly 2–3 mm on each side, so a slightly off cut doesn't leave a white sliver.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe area:&lt;/strong&gt; text and logos stay at least ~3 mm &lt;em&gt;inside&lt;/em&gt; the trim line so a slightly off cut doesn't clip them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With 3 mm bleed on every side, the artwork canvas is &lt;strong&gt;91.60 × 59.98 mm&lt;/strong&gt; (3.606 × 2.361 in). Always confirm which bleed the printer wants; 2 mm and 3 mm are both common.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pixel sizes
&lt;/h2&gt;

&lt;p&gt;Pixels = mm ÷ 25.4 × DPI. Rounded to whole pixels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Canvas&lt;/th&gt;
&lt;th&gt;300 DPI&lt;/th&gt;
&lt;th&gt;600 DPI&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Card only (85.60 × 53.98 mm)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1011 × 638 px&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2022 × 1275 px&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Card + 3 mm bleed (91.60 × 59.98 mm)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1082 × 708 px&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2164 × 1417 px&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Corner radius (3.18 mm)&lt;/td&gt;
&lt;td&gt;~38 px&lt;/td&gt;
&lt;td&gt;~75 px&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On screen, CSS treats 1 in as 96 px, so a "true size" card is about &lt;strong&gt;323.5 × 204 CSS px&lt;/strong&gt;. That's only physically accurate if the display and zoom happen to cooperate, which they usually don't (more on that below).&lt;/p&gt;

&lt;p&gt;Note the rounding: 637.56 px rounds up to 638. If you build a 1011 × 637 canvas, you've quietly changed the aspect ratio. Keep the mm values as your source of truth and derive the pixels from them.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS: a card that scales
&lt;/h2&gt;

&lt;p&gt;Percentage &lt;code&gt;border-radius&lt;/code&gt; is calculated separately against width and height, so &lt;code&gt;border-radius: 3.7%&lt;/code&gt; gives you slightly elliptical corners on a non-square box. Drive everything from one width variable instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;--w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;340px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                       &lt;span class="cm"&gt;/* any width you like */&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;aspect-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;85.6&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;53.98&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;3.18&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;85.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;135deg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;#12355b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;#1f8a8a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;8px&lt;/span&gt; &lt;span class="mi"&gt;24px&lt;/span&gt; &lt;span class="nf"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__safe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="cm"&gt;/* 3 mm safe margin, expressed relative to card width */&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;inset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;85.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make &lt;code&gt;.card&lt;/code&gt; &lt;code&gt;position: relative&lt;/code&gt; if you use the safe-area box for layout. For a print stylesheet you can use real units:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;85.6mm&lt;/span&gt; &lt;span class="mf"&gt;53.98mm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.card--print&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;85.6mm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;53.98mm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;3.18mm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Chromium honours &lt;code&gt;@page size&lt;/code&gt;; check your target browser before relying on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  SVG: millimetres as user units
&lt;/h2&gt;

&lt;p&gt;SVG is the most honest format for this, because you can make one user unit equal 1 mm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;xmlns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"http://www.w3.org/2000/svg"&lt;/span&gt;
     &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"91.6mm"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"59.98mm"&lt;/span&gt; &lt;span class="na"&gt;viewBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-3 -3 91.6 59.98"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- bleed area: background runs to the outer edge --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rect&lt;/span&gt; &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-3"&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-3"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"91.6"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"59.98"&lt;/span&gt; &lt;span class="na"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#12355b"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- trim line (rounded corners) --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rect&lt;/span&gt; &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"85.6"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"53.98"&lt;/span&gt; &lt;span class="na"&gt;rx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"3.18"&lt;/span&gt;
        &lt;span class="na"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt; &lt;span class="na"&gt;stroke&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#e33"&lt;/span&gt; &lt;span class="na"&gt;stroke-width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.2"&lt;/span&gt; &lt;span class="na"&gt;stroke-dasharray&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"1 1"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- safe area --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rect&lt;/span&gt; &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"3"&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"3"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"79.6"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"47.98"&lt;/span&gt;
        &lt;span class="na"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt; &lt;span class="na"&gt;stroke&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#3c3"&lt;/span&gt; &lt;span class="na"&gt;stroke-width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.2"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The negative &lt;code&gt;viewBox&lt;/code&gt; origin puts (0, 0) on the trim corner, so all your layout coordinates are measured from the card edge, the same way a printer measures them. Remember to strip the guide rectangles before exporting the final file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Canvas: export at print resolution
&lt;/h2&gt;

&lt;p&gt;For a downloadable PNG, render at 300 DPI regardless of the user's screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;25.4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;               &lt;span class="c1"&gt;// px per mm at 300 DPI&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;W&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;85.6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;H&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;53.98&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'canvas'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;W&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;MM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 1082&lt;/span&gt;
&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;H&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;MM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 708&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2d'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;MM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                   &lt;span class="c1"&gt;// now draw in millimetres&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;BLEED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c1"&gt;// (0,0) = trim corner&lt;/span&gt;

&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'#12355b'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;BLEED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;BLEED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;W&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;H&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;BLEED&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'#fff'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'4px system-ui'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// 4 mm font size (units are mm now)&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'MEMBER NAME'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;H&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// inside the 3 mm safe area&lt;/span&gt;

&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* download b */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/png'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For an on-screen preview, use &lt;code&gt;ctx.roundRect(0, 0, W, H, 3.18)&lt;/code&gt; as a clip to show the rounded corners. Don't bake the rounding into a print file, though: the corners are die-cut, and the printer wants square artwork.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using business card size.&lt;/strong&gt; 3.5 × 2 in (88.9 × 50.8 mm) and the European 85 × 55 mm are paper business cards, not CR80. The aspect ratio is different, so artwork gets stretched or cropped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rounding to 86 × 54.&lt;/strong&gt; Fine for a quick UI sketch, but not for print files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No bleed.&lt;/strong&gt; Backgrounds that stop exactly at the trim line give white edges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text hugging the edge.&lt;/strong&gt; Anything within ~3 mm of the trim is at risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;72 DPI exports.&lt;/strong&gt; A 324 × 204 px PNG looks fine on screen and prints soft. Export at 300 DPI minimum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring card features.&lt;/strong&gt; Magnetic stripes, contact chips, signature panels and slot punches each cover part of the card. Keep important detail out of those zones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trusting CSS mm on screen.&lt;/strong&gt; &lt;code&gt;85.6mm&lt;/code&gt; in CSS is 323.5 px at the CSS reference of 96 px per inch, not a physical measurement. If "actual size" matters, add a calibration step (for example, ask users to hold a real card against the screen and drag a slider).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sending rounded corners or guide lines.&lt;/strong&gt; Remove all guides before export.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Checking your output
&lt;/h2&gt;

&lt;p&gt;If you're generating card artwork in an app, it helps to drop the exported file over a template with the trim, bleed and safe lines drawn in. A free &lt;a href="https://plasticcard.nz/tools/card-artwork-checker/" rel="noopener noreferrer"&gt;CR80 artwork checker&lt;/a&gt; does exactly that in the browser (files aren't uploaded), and if you just need a quick starting design to test your pipeline with, there's a free &lt;a href="https://designer.plasticcard.nz/" rel="noopener noreferrer"&gt;online card designer&lt;/a&gt; as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CR80 = &lt;strong&gt;85.60 × 53.98 mm&lt;/strong&gt; = &lt;strong&gt;3.370 × 2.125 in&lt;/strong&gt;, corners ~&lt;strong&gt;3.18 mm&lt;/strong&gt;, ratio &lt;strong&gt;1.586&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;300 DPI: &lt;strong&gt;1011 × 638 px&lt;/strong&gt; (card), &lt;strong&gt;1082 × 708 px&lt;/strong&gt; (with 3 mm bleed).&lt;/li&gt;
&lt;li&gt;600 DPI: &lt;strong&gt;2022 × 1275 px&lt;/strong&gt; (card), &lt;strong&gt;2164 × 1417 px&lt;/strong&gt; (with 3 mm bleed).&lt;/li&gt;
&lt;li&gt;Keep mm as the source of truth, keep text 3 mm inside, run backgrounds 3 mm outside.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>design</category>
      <category>printing</category>
    </item>
    <item>
      <title>Why a card printing business built three free tools</title>
      <dc:creator>Allan Hall</dc:creator>
      <pubDate>Tue, 10 Nov 2026 03:08:17 +0000</pubDate>
      <link>https://dev.to/allanhall_plasticcard/why-a-card-printing-business-built-three-free-tools-1m64</link>
      <guid>https://dev.to/allanhall_plasticcard/why-a-card-printing-business-built-three-free-tools-1m64</guid>
      <description>&lt;p&gt;We supply custom-printed plastic cards to businesses around New Zealand: gift and loyalty cards, membership and staff ID, hotel keys, and RFID and NFC cards. The work is mostly B2B, often through print companies and brokers, and a lot of it depends on a file someone else has prepared.&lt;/p&gt;

&lt;p&gt;After enough jobs, the pattern was familiar. The delay was rarely the print itself. It was the artwork.&lt;/p&gt;

&lt;p&gt;A file would arrive at the wrong finished size — often a paper business-card format — or with no bleed, or with a logo sitting where the magnetic stripe has to go. A QR code would look crisp on screen and then fail on a phone once it was 15 millimetres wide on a glossy card. We check every file before it goes to print, and we should — a bad file should never become a bad run of cards. But going back and forth over details the sender could have seen earlier slows everyone down.&lt;/p&gt;

&lt;p&gt;So we built three free tools and put them on the web. They launched at the start of November 2026. Anyone can use them, whether or not they order from us. All three run in the browser. There is no account, and the first two never upload the user's file.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A checker that shows the card at its real size
&lt;/h2&gt;

&lt;p&gt;A standard plastic card is not “about 85 by 54”. It is a CR80 card, corresponding to the ID-1 format in ISO/IEC 7810: 85.60 × 53.98 mm, with rounded corners. Other features, such as contact chips, magnetic stripes, signature panels, slots, holes and RFID antennas, have their own placement and manufacturing requirements — they are not all fixed by that one size standard.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://plasticcard.nz/tools/card-artwork-checker/" rel="noopener noreferrer"&gt;artwork checker&lt;/a&gt; previews the front and back at that true size. You can set bleed and safe margins, switch on the features the card will actually have, and see where type and logos collide with a cut or a keep-clear zone. Blank templates download as layered PSD, SVG, PDF or PNG, so a designer can start from the right geometry instead of a business-card preset.&lt;/p&gt;

&lt;p&gt;Two decisions mattered to us here.&lt;/p&gt;

&lt;p&gt;The first was to do the check in the browser. Artwork stays on the user’s device; it is not uploaded to our servers. People are rightly cautious about sending print-ready files, especially when a card carries a logo, a staff layout or a client’s design. We thought people would be more comfortable testing the tool if their artwork stayed on their own machine.&lt;/p&gt;

&lt;p&gt;The second was to make the features optional and visible. A gift card with a three-track magnetic stripe (a stripe that can carry three data tracks) and a staff ID with a slot punch are the same finished size and completely different objects once you start placing a logo. A template that only shows a rectangle does not catch the mistakes that actually delay a job.&lt;/p&gt;

&lt;p&gt;I do not have a tidy figure for how many files used to arrive at the wrong page size, because we never set out to collect one. I can say it happened often enough that building a public checker felt more useful than writing the same notes back, job after job.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A QR generator that has to prove the code works
&lt;/h2&gt;

&lt;p&gt;Unscannable QR codes have a particular kind of frustration. The file looks fine. The designer followed a tutorial. Then the printed card does not open the page, usually because the code is too small, the contrast is too low, the quiet zone was cropped, or a logo was dropped into the middle with too little error correction. QR codes have four error-correction levels (L, M, Q and H); a higher level can tolerate more damage, but it is not a substitute for adequate contrast, a quiet zone of at least four modules on all four sides, or enough physical size.&lt;/p&gt;

&lt;p&gt;We did not want another generator that only draws a pattern. The &lt;a href="https://plasticcard.nz/tools/qr-code-generator/" rel="noopener noreferrer"&gt;QR code generator&lt;/a&gt; creates codes for websites, contact details, Wi-Fi and a range of other uses — 17 types in the current tool — and lets you set the printed size and add a logo. You can download vector artwork as SVG or PDF, or raster PNG at 300 or 600 dpi. Before each download, a software decoder attempts to read the generated artwork. If it cannot decode the code, you find out before downloading. That catches some generation problems, but it cannot guarantee that the printed result will scan.&lt;/p&gt;

&lt;p&gt;We still tell people to scan a printed sample at the final size, on a real phone. A decode on a large, bright monitor can hide problems that appear once the code is small, varnished or slightly off-colour. The physical size and the printer's reproduction quality matter as much as the file format.&lt;/p&gt;

&lt;p&gt;Two other constraints were deliberate. Everything runs in the browser, including the logo, so contact details and Wi-Fi passwords are not uploaded to us. And the codes are static: what you encode is what gets printed. There is no redirect subscription, no scan tracking and no file hosting. If you need a unique code on every card, that is variable data, and it belongs in the print run, supplied from a spreadsheet — not in a generator that pretends to give you a dashboard for free and then bills you later.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. An AI designer that keeps the wording intact
&lt;/h2&gt;

&lt;p&gt;The third tool came from a different gap. Some businesses do not have a designer on hand, and they still need a starting concept for a plastic business card — front and back, with their real wording, not a lorem-ipsum mock-up.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://designer.plasticcard.nz/" rel="noopener noreferrer"&gt;AI business card designer&lt;/a&gt; takes the exact details the user types and a short description of the look they want, and produces a front-and-back concept. We do not rewrite the wording. After a concept is generated, the wording and which side each detail appears on can still be adjusted in the tool. The generated images themselves are not edited in the interface; you download proof or print-quality files, and our team can amend them before production. Those downloads are a starting point for review, not a substitute for a pre-press check. The current interface allows three generations.&lt;/p&gt;

&lt;p&gt;We have been cautious about what we claim for it, because it is a project in development, not a replacement for professional design software. An image model can give you a direction in a minute. It cannot take responsibility for bleed, safe areas, a chip zone or whether the name is spelled as the customer intended.&lt;/p&gt;

&lt;p&gt;One practical quirk is worth being honest about. The designer uses an approximate 86 × 54 mm working canvas with 2 mm bleed on each edge, producing 90 × 58 mm artwork. That is close to the familiar credit-card format, but it is not the exact ISO ID-1 size of 85.60 × 53.98 mm. We therefore treat the output as a concept and check the final artwork against the exact CR80 template.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Put the inspection where the file is still cheap to change.&lt;/strong&gt; By the time a print supplier opens the artwork, a lot of decisions are already baked in. A public preview does not replace a pre-press check, and we have not pretended that it does. It does mean the first conversation can be about a real issue, not a missing 2 mm of bleed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the check can run locally, do not demand an upload.&lt;/strong&gt; Designers, printers and in-house marketers will try a tool more readily if the file never leaves their machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A generator that does not verify its output is unfinished.&lt;/strong&gt; This is especially true for QR codes, where a visually tidy mark can still be unreadable. We decided that checking whether the generated code could actually be decoded was more important than simply offering additional download options.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI is a starting point, and it should be labelled that way.&lt;/strong&gt; Over-claiming here would have been easy and unhelpful. The useful split is: the model drafts a look, the user keeps control of the words, and a person still signs off the print file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make the tools useful even if no order follows.&lt;/strong&gt; We wanted the tools to be useful before someone decided where to have their cards printed. That is when they can make the biggest difference to the artwork. Printers, designers and organisations preparing their own files can use them regardless.&lt;/p&gt;

&lt;p&gt;I would like to tell you how many reprints these tools have already prevented. I cannot: we did not instrument the work that way, and it would be guesswork to start now. What I can say is the original problem was real, the tools are free to use, and we still check the final file before anything is printed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Allan Hall works at PlasticCard.nz, a national supplier of custom-printed plastic cards for New Zealand businesses.&lt;/em&gt;&lt;/p&gt;

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