Code 2-of-5 Barcode Explained

Code 25 Example

Code 2-of-5 was one of the earliest linear barcode symbologies, originally introduced in the 1970s. The barcode is sometimes also referred to as Code 25 or Code 2/5. Several versions of Code 2-of-5 were developed over the years, the most important are Code 2-of-5 Standard (sometimes also called "Industrial") and Code 2-of-5 Interleaved. Only the latter ("Interleaved") is still in use; the "Standard"-version has fallen out of favor, mostly because it's not very efficient, see next paragraph. The term "two of five" originates from the fact that an individual symbol has five bars, two of which are wide.

The Interleaved version gets its name from the fact that each symbol encodes a pair of numbers; the first digit is encoded into the "bars" of a symbol, the second into the "spaces". This makes for a very compact code, even for larger amounts of data (the data density is comparable to Code 128 Type C which also features numeric compaction).

Here's an example of Code 25 Standard (module width 0.5mm):

Code 2 of 5 Standard Example

Compare to Code 2-of-5 Interleaved with same settings and data:

Code 2 of 5 Interleaved Example

Code 2-of-5 at a Glance

  • Type: Linear barcode symbology
  • Applications: Warehousing, transport, logistics, ITF-14
  • Character set: Digits 0-9
  • Modes: n/a
  • Check digit: Modulo 10 (not mandatory but recommended)
  • Generators: Stand-alone, barcode fonts, barcode extensions
  • Scanning: CCD / Laser scanners, imagers, scanner apps
  • Printing: Thermal direct, thermal transfer, laser, inkjet, dot-matrix

Note: Since only even amounts of digits can be encoded into an "Interleaved" barcode, it's common practice to either prepend a "0" or append a check digit if the data consists of an odd number of digits.

Code 2-of-5 maximum length

Code 2-of-5 is a variable length code, which in principle can encode an arbitrary length of data. The practical content limit is at around 30 digits before the code gets too wide.

Code 2-of-5 Interleaved with 30 digits, module width 0.4mm, total length c. 115mm (click for full size):

Code 25 maximum length

Note that many barcode scanners or reader apps may have soft limits below those numbers. Also, a barcode must not be wider than the "reading window" or aperture of a scanner or it won't be scanned.

Code 2-of-5 Bit Pattern

The Code 2-of-5 bit pattern (JavaScript array syntax) for the digits 0-9. Five elements for bars and spaces; '0' is a narrow element, '1' is a wide element.

const c25_bp =

Start / stop characters:

const c25_start =

const c25_stop =

Check digit calculation for Code 2-of-5

Code 2-of-5 (that goes for both variations) uses a Modulo 10 check digit algorithm which is identical to the calculation used for UPC-A and EAN 13. All digits are multiplied by 1 and 3 (alternating), added up and then modulo divided by 10. The reminder is subtracted from 10, the result is the checkdigit.

The barcode software that generates the code will usually calculate the check digit automatically if needed. Depending on the application the check digit may or may not be part of the humand readable text line.

Decoding Code 2-of-5

Manually decoding Code 2-of-5 is possible, beginning with the start symbol and going forward one character or pair of digits at a time. Afterwards, the validity of the decoded data has to be verified against the Modulo 10 check digit if present.

Code 2-of-5 fonts for Excel or Google Sheets

Code 2-of-5 Interleaved is a good choice for embedding barcodes with purely numeric data in your spreadsheet. Applications include catalogs with article numbers, serial numbers, personnel IDs or similar data. The easiest and most straight forward way of creating Code 2-of-5 barcodes in Excel or Google Sheets is with a Code 25 barcode font. In order to convert the data into pairs, add the required start/stop symbols and calculate the check digit, such a barcode font can only be used in conjunction with an add-in, for example the Softmatic barcode add-in for Excel.

Note, that it is not sufficient to simply select the cell with your data and change the font to "Code 2/5" (a common misconception with 2-of-5 barcode fonts that are freely available on the net).

Create Code 2-of-5 in Illustrator, InDesign

Easy to use barcode plug-ins and extensions for Adobe InDesign, Illustrator und Photoshop. For more videos, see the Softmatic Youtube Channel

The Softmatic barcode plug-ins and extensions for InDesign, Illustrator and Photoshop are available on the Adobe Exchange.

Code 2-of-5 Generator

Softmatic BarcodePlus V5 creates Code 25 Standard and Code 25 Interleaved will export the barcode as PDF / SVG (resolution-independent vector) oder raster image (PNG, TIFF):

Softmatic BarcodePlus Code 25 Generator

Code 2-of-5 Bulk Barcode Generator

For creating Code 2-of-5 Standard and Code 2-of-5 Interleaved in bulk, use Softmatic BarcodeFactory V5. The software will create thousands of barcode symbols in seconds, with data coming from the built-in serial number generator, the clipboard or via import from Excel, Numbers or CSV text files:

Code 128 REST APIs

Developers love our easy to use Barcode REST API for Code 2/5 Standard and Code 2/5 Interleaved. The Barcode API supports all common linear and 2D code symbologies and can be used from JavaScript / Node, Ruby, Python, PHP, Swift and many other languages and environments. The API comes with a generous free tier and is available through RapidAPI. Documentation and sample code are here.