npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@allansli/barcode-febraban-core

v2.0.1

Published

Vanilla JS encoder for Brazilian boleto ITF barcodes (Interleaved 2 of 5 / Febraban). Maps an even-length digit string to the BarcodeInterleaved2of5 font. Not EAN, UPC, Code 128, or a linha digitável converter.

Downloads

403

Readme

@allansli/barcode-febraban-core

Draw the barcode on a Brazilian boleto. That barcode is ITF (Interleaved 2 of 5), the symbology Febraban uses for the código de barras. @allansli/barcode-febraban-core is the vanilla JavaScript encoder: it turns an even-length digit string into the character sequence that BarcodeInterleaved2of5.ttf renders as the bars.

Pass digits you already have (the 44-digit código de barras is the usual input). This package does not parse a boleto, does not convert a 47-digit linha digitável into 44 digits, and does not compute the módulo-11 DAC.

The framework packages call this function:

Install

npm install @allansli/barcode-febraban-core

Minimal example

import { generateBarcodeSequence } from "@allansli/barcode-febraban-core";

const sequence = generateBarcodeSequence("1234567890");
console.log(sequence); // "(<RÆÜè)"

Put sequence in an element with class barcodei2of5 after loading assets/css/barcode.css. Host BarcodeInterleaved2of5.ttf yourself; npm does not ship the font.

When to use

  • You need an ITF (Interleaved 2 of 5) barcode for a Brazilian boleto (Febraban código de barras).
  • The input is a string of digits with even length. A 44-digit código de barras qualifies.
  • You want vanilla JS (ESM, CommonJS, or a browser script) and will render with BarcodeInterleaved2of5.ttf.

When not to use

  • EAN, UPC, Code 128, QR, or any symbology other than ITF.
  • You have a 47-digit linha digitável and need it converted. Odd length returns "". There is no 47→44 conversion.
  • You need the DAC (módulo 11) computed or checked.
  • You need a canvas or SVG barcode that does not use this font.
  • You want a component: use the React, Vue, Angular, or AngularJS package instead of calling this from a template by hand.

| Expectation | This package | |---|---| | 44-digit código de barras | Encodes (even length, digits only) | | 47-digit linha digitável | Returns "" — there is no conversion | | DAC (módulo 11) | Not computed or checked | | Odd length | Returns "" (no leading-zero pad) | | Non-digits / non-strings | Returns "" (does not throw) |


Other entry points

The minimal example is ESM (Vite, Webpack, Rollup). CommonJS and a browser script use the same function.

CommonJS (Node.js, older bundlers)

const { generateBarcodeSequence } = require("@allansli/barcode-febraban-core");

const sequence = generateBarcodeSequence("1234567890");

Browser (script tag)

<script src="node_modules/@allansli/barcode-febraban-core/src/generate-barcode-sequence.js"></script>
<script>
  var sequence = barcodeFebrabanCore.generateBarcodeSequence("1234567890");
</script>

The UMD entry src/index.js also works in Node/AMD. In a browser it expects the encoder script above (or a bundle that concatenates both).


API

generateBarcodeSequence(barcode)

Parameters

| Name | Type | Description | |---|---|---| | barcode | string | Digits only, even length |

Returns string — Font-encoded sequence wrapped in parentheses, or "" for invalid input (including null, numbers, odd length, and 47-digit linha digitável).

Encoding (for this font, not a generic ITF bit pattern):

  • Pairs 00–49 → charCode = pair + 48
  • Pairs 50–99 → charCode = pair + 142
  • Result wrapped in ( ) for the font’s start/stop bars
generateBarcodeSequence("1234567890");
// pairs: 12, 34, 56, 78, 90 → "(<RÆÜè)"

generateBarcodeSequence("0".repeat(47)); // linha digitável length
// ""

CSS & Font

Published npm packages include the CSS only. They do not include BarcodeInterleaved2of5.ttf (no redistributable license; see NOTICE).

The CSS still references the historical relative path:

@font-face {
  font-family: "BarcodeInterleaved2of5";
  src: url("../fonts/BarcodeInterleaved2of5.ttf") format("truetype");
}

Host a copy of that file (from this git tree for local demos, or a font you are licensed to use) at fonts/BarcodeInterleaved2of5.ttf next to css/, or override @font-face in your app.

<link rel="stylesheet" href="node_modules/@allansli/barcode-febraban-core/assets/css/barcode.css" />

Or in a bundler:

import "@allansli/barcode-febraban-core/assets/css/barcode.css";
<div class="barcodei2of5"><!-- sequence goes here --></div>

GitHub Pages demos load the TTF from packages/core/assets/fonts/ in this repo.


License

MIT © Allan Martins de Paula (source code). The TrueType font in git is not covered by MIT and is not published to npm; see NOTICE.