
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@point-of-sale/barcode-parser
Advanced tools
[](https://www.npmjs.com/@point-of-sale/barcode-parser) 
This library is part of @point-of-sale, a collection of libraries for interfacing browsers and Node with Point of Sale devices such as receipt printers, barcode scanners and customer facing displays.
This library provides common barcode parsing functions used by the WebHIDBarcodeScanner, WebSerialBarcodeScanner, WebcamBarcodeScanner and KeyboardBarcodeScanner libraries.
This library is not intended to be used as a standalone direct dependancy. There is no guarantee for a stable API.
To use this library you first need to install it:
npm i @point-of-sale/barcode-parser
And import it:
import { Aim, GS1, Detector, Symbologies } from '@point-of-sale/barcode-parser';
Some barcode scanners give back an AIM Code Identifier which gives information about the barcode symbology and certain other options.
To parse the AIM Code Identifier call the Aim.decode() function. It requires two parameters: the 3 character AIM Code Indentifier, starting with a ], and the remaining value of the barcode.
let result = Aim.decode(']E0', '3046920029759');
The result will be an object with a key for the symbology:
{
symbology: 'ean13'
}
Optionally there will be a key model for the QR code model and a key fnc1 that tells us if the FNC1 character is the first of second character of the encoded data.
Retail and warehouses often use barcodes that encode GS1 data. For example ITF-14, EAN and UPC barcodes encode the GS1 GTIN. Additionally a GS1 Digital Link QR Code, GS1 Datamatrix, GS1-128 or GS1 Databar can encode other GS1 elements.
To parse the GS1 data from a barcode you can call the GS1.decode() function. It only requires one parameter, an object with the following properties:
value3046920029759.symbologyean13.fnc1fnc1 property returned by the AIM.decode() function.For example:
let result = GS1.decode({
value: '3046920029759',
symbology: 'ean13'
});
Or:
let result = GS1.decode({
value: '010304692002975915251031',
symbology: 'gs1-128',
fnc1: 1
});
Or:
let result = GS1.decode({
value: 'https://example.com/01/03046920029759?15=251031',
symbology: 'qr-code'
});
The first one will result in an object with the GS1 GTIN as the only element:
{
gtin: '03046920029759',
elements: [
{
ai: '01',
label: 'GTIN',
value: '03046920029759'
}
]
}
The two below that will get an object with two elements:
{
gtin: '03046920029759',
elements: [
{
ai: '01',
label: 'GTIN',
value: '03046920029759'
}, {
ai: '15',
label: 'BEST BEFORE or BEST BY',
value: '251031'
}
]
}
The object that is returned contains the following properties:
gtinelementsai property for the application id, an label property containing a human readable description and value for the value of the element.Guess the symbology based on the format of the barcode. Call the Detector.detect() function with the barcode data as a parameter.
let result = Detector.detect('3046920029759')
This results in an object with the following properties:
symbologyguessThe example above will result this:
{
symbology: 'ean13',
guess: false
}
The barcode contains 13 digits, which makes it likely that it is a EAN-13 barcode. Additionally we've verified that the last digit is indeed the correct check digit, so we're pretty sure it is actually an EAN-13 barcode.
If the detector cannot make a determination what type of barcode it is, the function will return undefined.
Functions that help with specific symbologies. Right now there is only one function defined, for helping with UPC-E barcodes.
UPC-E barcodes are similar to UPC-A barcodes, but zero's in the barcode value are compressed, making the barcode physically smaller. Call the Symbologies.UPCE.expand() function to convert the compressed UPC-E barcode back to it's original value.
let result = Symbologies.UPCE.expand('02345673')
Will result in a string with the following value: 023456700003.
This library has been created by Niels Leenheer under the MIT license. Feel free to use it in your products. The development of this library is sponsored by Salonhub.
FAQs
[](https://www.npmjs.com/@point-of-sale/barcode-parser) 
The npm package @point-of-sale/barcode-parser receives a total of 1,762 weekly downloads. As such, @point-of-sale/barcode-parser popularity was classified as popular.
We found that @point-of-sale/barcode-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.