What is inside a barcode?

Every barcode is a sequence of named parts, and each part has a job. Hover any region of the diagrams below and it will tell you what that region is, how many modules it occupies and what would break if it were missing — for EAN-13, Code 128, Code 39, ITF-14 and QR Code. Then type any value and watch it become a module sequence, live, in your browser.

Everything here is computed, not illustrated. The symbols on this page are encoded from the symbology rules by code that ships with the page — no image files, no CDN and no barcode library. So the module counts and the per-character patterns in the panels are read out of the same data that draws the picture, and the two cannot drift apart. Nothing you type leaves the browser.

Pick a symbol and a value

Structure diagram

Hover, tap or tab through the regions. Selecting a region pins it so the panel below keeps showing it while you look at the rest of the symbol.

Nothing selected yet — hover or tab into the diagram and this panel will describe the region you are on.

Region by region

Region Role Modules What it does

Character by character

How the check value is computed

The five symbologies side by side

Structure at a glance
Symbology Kind Fixed structure Payload Error detection
EAN-13 1D 101 start guard + 6 digits + 01010 centre guard + 6 digits + 101 end guard = 95 modules, plus 11 and 7 modules of quiet zone 12 digits; the 13th is computed, and its value is carried by the parity of the left half, not by any bar of its own Modulo-10 check digit (weights 3, 1, 3, 1 …), verified by the decoder
Code 128 1D Start character + data + check symbol + stop character; every symbol character is 11 modules, the stop is 13 Any ASCII text, in one of three code sets; digits packed two to a character in set C Modulo-103 check symbol — a full 11-module character, not one digit
Code 39 1D * start + characters separated by a narrow gap + * stop; each character is 9 elements, 3 of them wide 43 characters: 0-9, A-Z, space and - . $ / + % Optional modulo-43 check character. Most Code 39 symbols carry no check at all
ITF-14 1D 1010 start + digit pairs + 11101 stop, printed inside a bearer bar Digits only, in pairs — one digit in the bars, the next in the spaces between them GTIN-14 check digit, and a self-checking element structure
QR Code 2D 3 finder patterns + separators + timing patterns + alignment patterns + format information, with data and error-correction codewords filling the rest Any text; numeric, alphanumeric or byte mode, chosen automatically Reed-Solomon error correction at one of four levels

How a scanner actually reads one

A linear barcode is not read as an image. A scanner sweeps one or more lines across the symbol, turns each line into a sequence of black and white runs, and measures their widths. From that run-length sequence it works out the module width, then converts each group of elements into a character using the symbology's table — which is why the tables on this page are worth looking at: they are the decode step.

  1. Find the symbol. The quiet zone is the only thing telling the scanner that a bar here is the beginning of a symbol rather than part of the packaging artwork.
  2. Measure the module. The narrowest run in the symbol is one module. Everything else is judged against it — a wide element is two or three times that width, and the ratio has to match what the symbology allows.
  3. Convert runs to characters. A group of elements becomes a character by looking its width pattern up in the symbology table. Code 39 gives nine elements per character; Code 128 gives six element widths summing to eleven modules; ITF gives ten interleaved elements per digit pair.
  4. Verify. The check digit or check character is recomputed and compared. This is what turns a plausible-looking misread into a rejected scan.
  5. Read the direction. Because the start and end patterns are different — the EAN-13 guards, the Code 128 stop bar, the ITF stop — a decoder can tell a reversed scan from a correct one, and either reject it or reverse it deliberately.

A 2D symbol is read as a grid instead. The finder patterns give the detector three corners, from which it can work out the symbol's scale, rotation and perspective; the timing patterns count the modules between them; and the format information tells the decoder which error-correction level and which of the eight masks was used, so it can unmask the grid before reading a single codeword.

Scope and notes

This page is an explainer, not a certified encoder. It implements the parts of EAN-13, Code 128, Code 39, ITF-14 and QR Code that make their structure visible and checkable: the module patterns, the character tables, the check-value arithmetic and the QR placement rules. It does not implement UPC/EAN extensions and add-ons, the Code 128 FNC1-4 function characters for GS1 application identifiers, Code 39 full-ASCII escapes, or the full ISO/IEC 18004 mode set beyond numeric, alphanumeric and byte.

Where a symbol's numbers come from. Every count on this page is derived from the encoded module sequence rather than typed in, so if the encoder and the description ever disagreed, the description would change — not the picture. The character tables themselves are the published symbology tables, written out in full in barcode-1d.js so they can be checked against the standard line by line.

Why the wide-to-narrow ratio is a choice. Code 39 permits a ratio between 2:1 and 3:1 and GS1 permits 2.25:1 to 3.0:1 for ITF, so two conformant symbols of the same value can have different widths. This page draws Code 39 and ITF at 3:1 because a module grid can only draw whole modules. That is why a Code 39 symbol here may be a little wider than one printed by another tool: both are correct, and the ratio is a print decision.

What a barcode is not. A barcode is not a secret and not a signature. Anyone with a phone can read every value on this page, and the check digit is an error-detection mechanism, not a security one — it catches misreads, not forgery. Keep test payloads synthetic.

To read real symbols — from a camera, an image, a PDF or a multi-page TIFF — use the online barcode scanner, which decodes 1D and 2D formats and reports the value, the symbology, the bounding box and the decode time. To produce symbols of your own, use the barcode and QR code generator.