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 🙏

© 2025 – Pkg Stats / Ryan Hefner

credit-card-brand-detector

v1.0.1

Published

Detects credit card brands/networks (Visa, Mastercard, Elo, etc.) with Luhn validation - supports 11 major brands including Brazilian cards

Readme

Credit Card Brand Detector

npm version npm downloads License: MIT

🇺🇸 English: Detects credit card brand/network based on card number patterns
🇧🇷 Português: Detecta a bandeira/marca de cartões de crédito baseado no padrão do número

Supported Brands / Bandeiras Suportadas

11 brands supported / 11 bandeiras suportadas:

  • Visa
  • Mastercard
  • American Express
  • Diners Club
  • Discover
  • EnRoute
  • JCB
  • Voyager
  • Hipercard
  • Aura
  • Elo

Installation / Instalação

npm install credit-card-brand-detector

NPM Package: https://www.npmjs.com/package/credit-card-brand-detector

Usage / Como Usar

English

const { validateCreditCard, detectBrand, getBrand } = require('credit-card-brand-detector');

// Detect brand and validate
const result = validateCreditCard('4532015112830366');
console.log(result);
// Output: { isValid: true, bandeira: 'Visa' }

// Just detect the brand (two ways - same function)
const brand1 = detectBrand('5555555555554444');
const brand2 = getBrand('5555555555554444');
console.log(brand1); // Output: 'Mastercard'
console.log(brand2); // Output: 'Mastercard'

Português

const { validateCreditCard, detectBrand, getBrand } = require('credit-card-brand-detector');

// Detectar bandeira e validar
const resultado = validateCreditCard('4532015112830366');
console.log(resultado);
// Saída: { isValid: true, bandeira: 'Visa' }

// Apenas detectar a bandeira (duas formas - mesma função)
const bandeira1 = detectBrand('5555555555554444');
const bandeira2 = getBrand('5555555555554444');
console.log(bandeira1); // Saída: 'Mastercard'
console.log(bandeira2); // Saída: 'Mastercard'

API Reference / Referência da API

validateCreditCard(cardNumber)

English: Validates a credit card number and detects its brand
Português: Valida um número de cartão de crédito e detecta sua bandeira

Parameters / Parâmetros:

  • cardNumber (string): Credit card number / Número do cartão de crédito

Returns / Retorna:

{
  isValid: boolean,    // Luhn validation result / Resultado da validação Luhn
  bandeira: string|null // Brand name or null / Nome da bandeira ou null
}

detectBrand(cardNumber) | getBrand(cardNumber)

English: Detects only the credit card brand (both functions are identical)
Português: Detecta apenas a bandeira do cartão de crédito (ambas as funções são idênticas)

Parameters / Parâmetros:

  • cardNumber (string): Credit card number / Número do cartão de crédito

Returns / Retorna:

  • string|null: Brand name or null if not recognized / Nome da bandeira ou null se não reconhecida

Examples / Exemplos

// Different card brands / Diferentes bandeiras
// Using detectBrand
console.log(detectBrand('4532015112830366')); // 'Visa'
console.log(detectBrand('5555555555554444')); // 'Mastercard'
console.log(detectBrand('378282246310005'));  // 'American Express'

// Using getBrand (same results)
console.log(getBrand('30569309025904'));   // 'Diners Club'
console.log(getBrand('6011111111111117')); // 'Discover'
console.log(getBrand('201400000000009'));  // 'EnRoute'
console.log(getBrand('3530111333300000')); // 'JCB'
console.log(getBrand('8699000000000001')); // 'Voyager'
console.log(getBrand('6062000000000001')); // 'Hipercard'
console.log(getBrand('4869330000000001')); // 'Aura'

Features / Características

🇺🇸 English:

  • ✅ Detects 11 major credit card brands
  • ✅ Includes Brazilian brands (Hipercard, Aura, Elo)
  • ✅ Luhn algorithm validation
  • ✅ Handles spaces and hyphens in card numbers
  • ✅ Zero dependencies
  • ✅ Comprehensive unit tests
  • ✅ Multiple function names for flexibility (detectBrand and getBrand)

🇧🇷 Português:

  • ✅ Detecta 11 principais bandeiras de cartão
  • ✅ Inclui bandeiras brasileiras (Hipercard, Aura, Elo)
  • ✅ Validação por algoritmo de Luhn
  • ✅ Remove espaços e hífens dos números
  • ✅ Zero dependências
  • ✅ Testes unitários abrangentes
  • ✅ Múltiplos nomes de função para flexibilidade (detectBrand e getBrand)

License / Licença

MIT License - see LICENSE file.

Links

About

Developed by Fernando Paladini, using GitHub Copilot for DIO bootcamp challenge.

References