Overview
This node enables barcode generation and scanning using the ZXing library. It supports a wide variety of barcode formats including QR Code, Code 128, EAN, UPC, Data Matrix, PDF 417, Aztec, and others.
- Generate Operation: Converts input text into a barcode image with customizable format, size, margin, and error correction level (for QR codes). Useful for creating barcodes for product labels, tickets, or encoding URLs and data.
- Scan Operation: Decodes barcodes from images provided as binary data or base64 strings. Supports multiple image processing attempts to improve decoding success. Ideal for extracting information from scanned barcodes in workflows.
Practical examples:
- Automatically generate QR codes for URLs or contact info to embed in emails or documents.
- Scan product barcodes from uploaded images to retrieve product IDs or inventory data.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between "Generate" (create barcode) or "Scan" (decode barcode from image). |
When Operation = Generate
| Name | Meaning |
|---|---|
| Barcode Format | The type of barcode to generate. Options: QR Code, Code 128, Code 39, Code 93, EAN-8, EAN-13, UPC-A, UPC-E, Data Matrix, PDF 417, Aztec, Codabar, ITF. |
| Text to Encode | The text or data string to encode into the barcode. |
| Width | Width of the generated barcode image in pixels. |
| Height | Height of the generated barcode image in pixels. |
| Error Correction Level | For QR Codes only: level of error correction to apply. Options: Low ( |
| Margin | Margin (quiet zone) around the barcode in pixels. |
When Operation = Scan
| Name | Meaning |
|---|---|
| Image Source | Source of the image to scan: "Binary Data" (from previous node's binary output) or "Base64" string. |
| Binary Property | (If Image Source is Binary) Name of the binary property containing the image data. |
| Base64 Data | (If Image Source is Base64) Base64 encoded image string to decode. |
| Try Harder | Whether to enable more intensive decoding attempts (slower but more accurate). |
| Return Format Info | Whether to include detected barcode format details in the output. |
Output
Generate Operation outputs an object per input item with:
jsoncontaining:format: barcode format usedtext: original text encodedwidth,height: dimensions of the generated imagesize: size in bytes of the PNG image buffer
binary.data: PNG image data of the generated barcode encoded as base64, with appropriate MIME type and file extension.
Scan Operation outputs an object per input item with:
jsoncontaining:text: decoded text from the barcode- Optionally, if enabled:
format: human-readable barcode format nameformatType: internal barcode format identifier
timestamp: timestamp of decodingnumBits: number of bits decodedimageInfo: width, height, and channels of the processed image
pairedItem: index linking output to input item
Dependencies
- Uses the ZXing library (
@zxing/library) for barcode encoding and decoding. - Uses
sharpfor image processing tasks such as resizing, greyscale conversion, normalization, sharpening, and raw pixel manipulation. - No external API keys or credentials are required.
- Requires n8n environment capable of handling binary data and image buffers.
Troubleshooting
Common Issues:
- Missing or empty "Text to Encode" when generating barcodes will cause an error.
- Providing invalid or missing binary/base64 image data for scanning will cause errors.
- Poor image quality, colored backgrounds, damaged barcodes, or low resolution may prevent successful scanning.
Error Messages:
"Text to encode is required for generation": Ensure the input text property is not empty."No binary data found for property ...": Verify that the previous node outputs binary data under the specified property name."Base64 data is required for scanning": Provide valid base64 image data when selected as source."No barcode found in the provided image...": Try enabling "Try Harder", use higher quality images, or better lighting conditions."Failed to decode barcode after trying multiple image processing approaches": Indicates decoding failed despite multiple attempts; check image validity and barcode visibility."Failed to process image...": Input might not be a valid image file; verify input data.
Links and References
- ZXing ("Zebra Crossing") Library: https://github.com/zxing/zxing
- Sharp Image Processing Library: https://sharp.pixelplumbing.com/
- Barcode Formats Reference: https://en.wikipedia.org/wiki/List_of_barcode_symbologies
- QR Code Error Correction Levels: https://www.thonky.com/qr-code-tutorial/error-correction