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

@thiagoprazeres/pix-static-brcode

v1.0.1

Published

Generate, parse and validate Brazilian Pix static BR Code (EMV QRCPS-MPM) — zero runtime dependencies

Readme

@thiagoprazeres/pix-static-brcode

npm license

Generate, parse and validate Brazilian Pix static BR Code (EMV QRCPS-MPM) — CRC-16/CCITT included, zero runtime dependencies.

Implements the Manual do BR Code and Manual de Padrões para Iniciação do Pix published by BACEN.

Install

npm install @thiagoprazeres/pix-static-brcode

Usage

Generate

import {
  generateStaticBrCode,
  projectReceiverName,
  projectCity,
  buildBrCodeRef,
} from '@thiagoprazeres/pix-static-brcode';

const payload = generateStaticBrCode({
  pixKey: '11999998888',
  receiverName: projectReceiverName('João da Silva'),  // → 'JOAO DA SILVA'
  receiverCity: projectCity('São Paulo'),               // → 'SAO PAULO'
  referenceLabel: buildBrCodeRef(crypto.randomUUID()),
  amount: 99.90,
  description: 'Pedido #1234',
});
// → '000201...<EMV payload>...6304XXXX'

Parse

import { parseStaticBrCode } from '@thiagoprazeres/pix-static-brcode';

const parsed = parseStaticBrCode(payload);
// {
//   pixKey: '11999998888',
//   receiverName: 'JOAO DA SILVA',
//   receiverCity: 'SAO PAULO',
//   referenceLabel: '...',
//   amount: 99.90,
//   description: 'Pedido #1234'
// }

Throws Error if the payload is malformed or the CRC-16 checksum is invalid.

Validate

import { validateCrc16, isValidBrCode } from '@thiagoprazeres/pix-static-brcode';

validateCrc16(payload); // true / false — checksum only
isValidBrCode(payload); // true / false — full validation, never throws

API

generateStaticBrCode(params: BrCodeParams): string

Generates a static Pix BR Code EMV payload with CRC-16/CCITT checksum.

interface BrCodeParams {
  pixKey: string;         // CPF, CNPJ, email, phone or EVP
  receiverName: string;   // already projected (no accents, uppercase, max 25)
  receiverCity: string;   // already projected (no accents, uppercase, max 15)
  referenceLabel: string; // max 25 alphanumeric chars
  amount?: number;        // omit for open-value charges
  description?: string;
}

parseStaticBrCode(payload: string): ParsedBrCode

Parses a static BR Code payload. Validates CRC-16 before parsing. Throws on invalid input.

interface ParsedBrCode {
  pixKey: string;
  receiverName: string;
  receiverCity: string;
  referenceLabel?: string;
  amount?: number;
  description?: string;
}

validateCrc16(payload: string): boolean

Returns true if the last 4 chars match the CRC-16/CCITT checksum of the rest. Never throws.

isValidBrCode(payload: string): boolean

Full validation (CRC + required fields). Never throws.

Projections

projectReceiverName(name: string): string
// Remove accents, strip non-alphanumeric, uppercase, truncate to 25 chars

projectCity(city: string): string
// Remove accents, strip non-alphanumeric, uppercase, truncate to 15 chars

buildBrCodeRef(id: string): string
// Strip hyphens from UUID, uppercase, truncate to 25 chars

EMV field map

| Tag | Field | Value | |-----|-------|-------| | 00 | Payload Format Indicator | 01 | | 26 | Merchant Account Info | br.gov.bcb.pix + key + description | | 52 | Merchant Category Code | 0000 | | 53 | Transaction Currency | 986 (BRL) | | 54 | Transaction Amount | omitted if open-value | | 58 | Country Code | BR | | 59 | Merchant Name | projected receiver name | | 60 | Merchant City | projected city | | 62/05 | Reference Label | charge reference | | 63 | CRC-16/CCITT | 4-char hex checksum |

Motivation

Generating a valid Pix static BR Code requires correct EMV TLV encoding, specific field ordering, string normalization per BACEN spec, and a CRC-16/CCITT checksum. No standalone, zero-dependency package covered all three aspects (generation, parsing, and CRC validation) before this one.

Scope

  • Generates static Pix BR Code payloads per BACEN spec
  • Parses static BR Code payloads back to structured objects
  • Validates CRC-16/CCITT checksums
  • Normalizes receiver name, city, and reference label per spec

Out of scope

  • Does not generate QR Code images (use a QR library on top)
  • Does not validate Pix key format semantically (CPF checksum, email format, etc.)
  • Does not handle dynamic BR Code / Pix cobrança com vencimento
  • Does not make any network requests

References

License

Apache 2.0