GS1 DataMatrix Generator
The 2D symbol for small packs, healthcare and direct part marking. Put in application identifiers; get a symbol with FNC1 where it belongs, and the printed size in millimetres before you send it to a label.
🔒 Your data never leaves your browser — the symbol is encoded here.
What makes a DataMatrix a GS1 DataMatrix
One codeword: FNC1 in the first position. Without it the symbol is a plain
DataMatrix carrying a string of digits, and a scanner has no reason to read
0104006381333931 as a GTIN. With it, the scanner emits the
]d2 symbology identifier and parsing systems know to split the data into
application identifiers. Everything else — the modules, the error correction, the size — is
identical.
Quiet zone: one module, and it is easy to lose
A linear GS1-128 needs ten times its X-dimension of clear space on each side. DataMatrix needs exactly one module — which is why it fits where a linear symbol cannot, and why label templates so often crop it away. The download here includes that one module.
Printed size is the decision, not the module count
A 20×20 symbol at 0.5 mm prints 11 mm square; the same symbol at 0.396 mm prints under 9 mm. The tool shows both numbers as you change the X-dimension so the choice is made before the label is ordered rather than after.
How this encoder is verified
It is written here rather than pulled from a library, because this site's core carries no
runtime dependencies. That only earns trust with evidence, so every release runs two
independent checks: bwip-js (a different implementation) generates the same
data and the matrices are compared module by module, and zxing decodes a
rasterised image of our symbol back to the original string. Both run in
pnpm test.
Two limits are stated rather than hidden: this encoder emits ASCII encodation only, so a symbol with mixed letters and digits can come out one size larger than an encoder that also implements C40 — the data is identical and any scanner reads it. And it builds square symbols up to 52×52; more data than that is refused with the reason rather than truncated.
Every check this tool runs before it draws anything (12 rules)
The element string is validated with the same engine — and the same rule numbers — as the GS1 element string builder. Nothing is drawn while any of these fails: a symbol that scans into a wrong GTIN is worse than a blank label.
LGL-001 Nothing to encode
A logistic label needs at least the SSCC.
LGL-002 Unknown Application Identifier
Only AIs in the GS1 AI table are encoded — an unknown AI would produce a barcode receivers cannot parse.
LGL-003 Duplicate AI
Each Application Identifier may occur only once on a logistic label.
LGL-004 Wrong length for a fixed-length AI
Fixed-length AIs (SSCC = 18 digits, GTIN = 14) must match exactly.
LGL-005 Value too long or empty
Variable-length AI values must be non-empty and within their maximum.
LGL-006 Invalid YYMMDD date
Date AIs are YYMMDD. DD may be "00" to mean end-of-month for best-before/expiry dates.
LGL-007 Check digit fails
SSCC and GTIN carry a GS1 mod-10 check digit. A wrong one is rejected at every receiving scanner; the expected digit is shown.
LGL-008 Character outside the GS1 character set
Values must use GS1 CSET 82 characters (letters, digits, and a limited set of punctuation).
LGL-011 Over 48 data characters
A GS1-128 symbol carries at most 48 data characters, counting AIs and separator FNC1s (not the start, leading FNC1, check or stop characters).
Fix: Drop a field — usually the batch — or split data across two labels.
GS1B-001 The encoded string does not parse back into what went in
Every string this tool builds is fed straight back into the GS1 parser and compared element by element with the input. If they differ, the output is withheld: a barcode that this site cannot read back is not one anybody else should have to.
Fix: This is a fault in the tool, not in your data — the input that produced it is worth reporting.
Source: yaktool self-check, not a GS1 rule: it is the round-trip property that makes a generator provable rather than merely plausible.
GS1B-002 FNC1 separators inserted after variable-length elements
A variable-length element must be terminated by FNC1 unless it is the last one in the string. Both halves of that rule get broken in practice: encoders that omit the separator run two fields together, and encoders that add a trailing one produce a non-conformant symbol.
GS1B-003 Predefined-length AIs moved to the front
AIs whose length is fixed by their first two digits need no separator, so putting them first removes FNC1 characters from the middle of the string and makes the symbol shorter. The data itself is unchanged — only the order of the elements.