Xerobit

Pharmacode Generator: Create Pharmaceutical Barcodes

Enter a number between 3 and 131070 to generate a Pharmacode barcode as an SVG image. Pharmacode is a one-dimensional barcode used in pharmaceutical packaging to verify products. This pharmacode generator runs entirely in your browser, so nothing is uploaded to any server.

Result

  • Encoded value
    12345
  • Bars
    13
  • Pattern
    WNNNNNNWWWNWN

    Left to right: N = narrow bar, W = wide bar

  • Narrow / wide bars
    8 / 5
  • Width (SVG units)
    118

How to use the pharmacode generator

  1. Enter an integer between 3 and 131070 in the value field.
  2. Choose a white or transparent background for the barcode.
  3. Click Generate to create the Pharmacode SVG.
  4. Copy the SVG markup or save it for use on pharmaceutical packaging.

How Pharmacode encoding works

Pharmacode is a one-track barcode that stores a whole number as a row of narrow and wide bars. It is read from the right. At each step, an odd number gives a narrow bar and becomes (n - 1) / 2, while an even number gives a wide bar and becomes (n - 2) / 2. The process stops when the number reaches zero.

Take 10 as an example:

  • 10 is even: wide bar, then (10 - 2) / 2 = 4
  • 4 is even: wide bar, then (4 - 2) / 2 = 1
  • 1 is odd: narrow bar, then (1 - 1) / 2 = 0

The bars were produced right to left, so the barcode reads narrow, wide, wide from left to right, written NWW. The default value 12345 gives the 13-bar pattern WNNNNNNWWWNWN.

Bar width reference table

A Pharmacode symbol has two bar widths and one constant gap. This pharmacode generator draws the wide bar three times as wide as the narrow bar and uses abstract SVG units, so you can scale the file to the physical size your printer and scanner need.

ElementLetterWidth (SVG units)
Narrow barN2
Wide barW6
Gap between bars-4
Quiet zone each side-12

Check the printed bar and gap sizes with your packaging line's reader before a production run, since readers are configured for specific dimensions.

Why the range is 3 to 131070

Pharmacode values start at 3 because 1 and 2 would each be a single bar, and a one-bar symbol cannot be told apart from a stray mark. The smallest valid value, 3, is two narrow bars.

The maximum value of 131070 is the largest number that fits in 16 bars. Sixteen wide bars give 217 - 2 = 131070, and 131069 is fifteen wide bars followed by a narrow bar on the right. Numbers can have between 2 and 16 bars in this tool. If you need to encode larger identifiers, use a different symbology such as those produced by a general barcode generator.

Pharmacode in pharmaceutical packaging

Pharmacode was developed specifically for the pharmaceutical industry. It appears on medication cartons, blister packs, and labels as a quality control measure. Because it encodes only a number without human-readable text beneath it, packaging lines rely on automated scanners to read the bars and verify that the correct product is inside the box.

Unlike retail barcodes such as EAN-13 or UPC-A, Pharmacode does not carry pricing or product category data. It is strictly an internal verification code. Production systems often pair it with other checks, similar to how a GTIN validator confirms retail codes before printing.

Common mistakes when generating Pharmacode

Several errors can produce an invalid or unreadable barcode:

  • Using decimals or fractions. Pharmacode only accepts whole integers. Entering 5.5 will fail.
  • Values outside the range. Numbers below 3 or above 131070 have no valid encoding.
  • Insufficient quiet zones. Scanners require clear space on both sides of the barcode. Always leave at least 10 units of blank space around the symbol.
  • Poor contrast. Bars must be significantly darker than the background. Black bars on white or transparent backgrounds work best.

This pharmacode generator handles validation automatically and adds standard quiet zones to every SVG it produces.

Worked examples

ExampleInputResult
Small value (3)Numeric value: 3; Background: whiteEncoded value: 3; Bars: 2; Pattern: NN; Narrow / wide bars: 2 / 0; Width (SVG units): 32
Typical product codeNumeric value: 12345; Background: whiteEncoded value: 12345; Bars: 13; Pattern: WNNNNNNWWWNWN; Narrow / wide bars: 8 / 5; Width (SVG units): 118
Maximum valueNumeric value: 131070; Background: transparentEncoded value: 131070; Bars: 16; Pattern: WWWWWWWWWWWWWWWW; Narrow / wide bars: 0 / 16; Width (SVG units): 180

FAQ

What is a Pharmacode barcode?

Pharmacode is a one-dimensional barcode symbology used exclusively in the pharmaceutical industry. It encodes a single integer between 3 and 131070 using narrow and wide bars to verify packaging contents.

Why does this pharmacode generator start at 3?

Values 1 and 2 would each be a single bar, which the specification does not allow, and 0 has no bars. The smallest valid number is 3, drawn as two narrow bars.

Can I scan a Pharmacode with my phone camera?

Most standard phone camera apps do not recognize Pharmacode because it lacks human-readable text and is meant for industrial scanners. You need a dedicated barcode scanning app that supports the Pharmacode symbology.

Is any data uploaded when I use this tool?

No. The entire encoding process happens locally in your browser. Your numeric value never leaves your device.

How many bars can a Pharmacode have?

A valid Pharmacode has between 2 and 16 bars. The maximum value of 131070 is exactly 16 wide bars.

What is the difference between Pharmacode and Code 128?

Code 128 can encode full alphanumeric strings and is used across many industries. Pharmacode encodes only a single number and is designed solely for pharmaceutical packaging verification.