PHPackages                             creditcard/identifier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. creditcard/identifier

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

creditcard/identifier
=====================

Credit Card BIN validation using bin-cc data

805JavaScriptCI failing

Since Jan 15Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/renatovico/bin-cc)[ Packagist](https://packagist.org/packages/creditcard/identifier)[ RSS](/packages/creditcard-identifier/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Credit Card BIN Data
====================

[](#credit-card-bin-data)

**This is a data file project** similar to tzdata, providing credit card BIN (Bank Identification Number) patterns as a source of truth for other libraries.

This repository contains authoritative data about credit card BIN patterns for validation and brand identification, along with reference implementations in multiple programming languages.

The original idea came from this [gist](https://gist.github.com/erikhenrique/5931368) by Erik Henrique.

After a JavaScript-only creditcard version, I found myself looking for this in other languages. With a bit of vibe coding style, I created libs for all languages I need (come contribute with more!). The idea is to generate from a source of truth in JSON to language-specific native code, avoiding the overhead of loading JSON files at runtime.

📁 Project Structure
-------------------

[](#-project-structure)

```
bin-cc/
├── data/                    # Credit card BIN data
│   ├── sources/            # Source data files (editable)
│   │   ├── visa/          # Subfolder for complex brands
│   │   │   ├── base.json
│   │   │   └── bins-*.json
│   │   ├── mastercard.json
│   │   └── ...
│   ├── compiled/           # Compiled output formats
│   │   ├── cards.json      # Simplified regex format
│   │   └── cards-detailed.json  # Full detailed format
│   ├── SCHEMA.md           # Data schema documentation
│   └── README.md           # Data usage guide
│
├── scripts/                # Build and validation tools
│   ├── build.js           # Compiles source → compiled data
│   ├── validate.js        # Standalone validation CLI
│   ├── create-card.js     # Interactive card creation CLI
│   └── lib/               # Shared modules
│
├── libs/                   # Reference implementations
│   ├── javascript/        # Each lib includes example.{ext}
│   ├── python/
│   ├── ruby/
│   ├── elixir/
│   ├── dotnet/
│   ├── java/
│   ├── rust/
│   ├── go/
│   └── php/
│
├── CONTRIBUTING.md         # Contribution guidelines
├── LICENSE                 # MIT License
└── package.json            # Build scripts

```

🎯 Data Source
-------------

[](#-data-source)

The **authoritative data** follows a **build system** similar to browserslist:

- **Source files** [`data/sources/`](./data/sources) - Human-editable card scheme definitions
- **Build script** [`scripts/build.js`](./scripts/build.js) - Compiles and validates data
- **Detailed output** [`data/compiled/cards-detailed.json`](./data/compiled/cards-detailed.json) - Full details with BINs
- **Simplified output** [`data/compiled/cards.json`](./data/compiled/cards.json) - Regex patterns only
- **Schema docs** [`data/SCHEMA.md`](./data/SCHEMA.md) - Complete schema documentation

### Building the Data

[](#building-the-data)

```
npm run build
```

This compiles source files into both detailed and simplified formats with validation.

### Validating Data

[](#validating-data)

```
# Validate all sources
node scripts/validate.js

# Validate specific file or directory
node scripts/validate.js data/sources/visa
node scripts/validate.js data/sources/amex.json
```

### Creating New Card Schemes

[](#creating-new-card-schemes)

```
node scripts/create-card.js
```

Interactive CLI to create new card scheme source files.

📚 Library Implementations
-------------------------

[](#-library-implementations)

All libraries provide the same core functionality for credit card BIN validation and brand identification.

### JavaScript/Node.js

[](#javascriptnodejs)

Complete implementation in [`libs/javascript/`](./libs/javascript/)

```
npm install creditcard-identifier
```

```
const cc = require('creditcard-identifier');
console.log(cc.findBrand('4012001037141112')); // 'visa'
```

### Python

[](#python)

Complete implementation in [`libs/python/`](./libs/python/)

```
pip install creditcard-identifier
```

```
from creditcard_identifier import find_brand
print(find_brand('4012001037141112'))  # 'visa'
```

### Ruby

[](#ruby)

Complete implementation in [`libs/ruby/`](./libs/ruby/)

```
gem install creditcard-identifier
```

```
require 'creditcard_identifier'
puts CreditcardIdentifier.find_brand('4012001037141112')  # 'visa'
```

### Elixir

[](#elixir)

Complete implementation in [`libs/elixir/`](./libs/elixir/)

```
# mix.exs
{:creditcard_identifier, "~> 1.0"}

# usage
CreditcardIdentifier.find_brand("4012001037141112")  # "visa"
```

### .NET/C#

[](#netc)

Complete implementation in [`libs/dotnet/`](./libs/dotnet/)

```
dotnet add package CreditCardIdentifier
```

```
using CreditCardIdentifier;
CreditCard.FindBrand("4012001037141112");  // "visa"
```

### Java

[](#java)

Complete implementation in [`libs/java/`](./libs/java/)

```

    br.com.s2n.creditcard
    creditcard-identifier
    2.1.0

```

```
import br.com.s2n.creditcard.identifier.CreditCardValidator;

CreditCardValidator validator = new CreditCardValidator();
validator.findBrand("4012001037141112");  // "visa"
```

### Rust

[](#rust)

Complete implementation in [`libs/rust/`](./libs/rust/)

```
# Cargo.toml
[dependencies]
creditcard-identifier = "2.1.0"
```

```
use creditcard_identifier::*;
find_brand("4012001037141112");  // Some("visa")
```

### Go

[](#go)

Complete implementation in [`libs/go/`](./libs/go/)

```
go get github.com/renatovico/bin-cc/libs/go
```

```
import creditcard "github.com/renatovico/bin-cc/libs/go"

brand := creditcard.FindBrand("4012001037141112")  // "visa"
```

### PHP

[](#php)

Complete implementation in [`libs/php/`](./libs/php/)

```
composer require creditcard/identifier
```

```
use CreditCard\Identifier\CreditCardValidator;

$validator = new CreditCardValidator();
$validator->findBrand('4012001037141112');  // "visa"
```

🎴 Supported Card Brands
-----------------------

[](#-supported-card-brands)

See [data/compiled/BRANDS.md](./data/compiled/BRANDS.md) for the auto-generated list of supported card brands.

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! This project follows a **source → build → compiled** workflow:

1. **Data updates:** Edit source files in [`data/sources/`](./data/sources)
2. **Build:** Run `npm run build` to compile and validate
3. **Test:** Ensure `npm test` passes
4. **Document:** Cite sources in your PR description

See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for detailed guidelines.

### Quick Start for Contributors

[](#quick-start-for-contributors)

```
# Create a new card scheme interactively
node scripts/create-card.js

# Or edit a source file manually
vim data/sources/visa/base.json

# Build and validate
npm run build

# Test
npm test

# Commit changes (both source and generated files)
git add data/
git commit -m "Update Visa BIN patterns"
```

📦 Publishing Libraries
----------------------

[](#-publishing-libraries)

All libraries are published to their respective package registries for easy installation:

LanguageRegistryInstallation CommandJavaScript[npm](https://www.npmjs.com/package/creditcard-identifier)`npm install creditcard-identifier`Python[PyPI](https://pypi.org/project/creditcard-identifier/)`pip install creditcard-identifier`Ruby[RubyGems](https://rubygems.org/gems/creditcard-identifier)`gem install creditcard-identifier`Elixir[Hex.pm](https://hex.pm/packages/creditcard_identifier)`{:creditcard_identifier, "~> 2.1"}`.NET/C#[NuGet](https://www.nuget.org/packages/CreditCardIdentifier/)`dotnet add package CreditCardIdentifier`Java[Maven Central](https://search.maven.org/artifact/br.com.s2n.creditcard/creditcard-identifier)See [libs/java](libs/java/)Rust[crates.io](https://crates.io/crates/creditcard-identifier)`cargo add creditcard-identifier`Go[pkg.go.dev](https://pkg.go.dev/github.com/renatovico/bin-cc/libs/go)`go get github.com/renatovico/bin-cc/libs/go`PHP[Packagist](https://packagist.org/packages/creditcard/identifier)`composer require creditcard/identifier`### For Library Maintainers

[](#for-library-maintainers)

To publish new versions of the libraries, see the [RELEASE.md](RELEASE.md) guide. Each library also has its own `PUBLISH.md` file with detailed instructions:

- [Java Publishing Guide](libs/java/PUBLISH.md)
- [Rust Publishing Guide](libs/rust/PUBLISH.md)
- [Go Publishing Guide](libs/go/PUBLISH.md)
- [PHP Publishing Guide](libs/php/PUBLISH.md)

All new libraries support automated publishing via GitHub Actions when you create a release with the appropriate tag format (e.g., `java-v2.1.0`).

📝 License
---------

[](#-license)

MIT License

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance48

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/299319?v=4)[Renato Viço](/maintainers/renatovico)[@renatovico](https://github.com/renatovico)

---

Top Contributors

[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (50 commits)")[![renatovico](https://avatars.githubusercontent.com/u/299319?v=4)](https://github.com/renatovico "renatovico (50 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (23 commits)")[![erikhenrique](https://avatars.githubusercontent.com/u/1441720?v=4)](https://github.com/erikhenrique "erikhenrique (9 commits)")[![leonardothibes](https://avatars.githubusercontent.com/u/1135830?v=4)](https://github.com/leonardothibes "leonardothibes (5 commits)")[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (2 commits)")[![eduBKR](https://avatars.githubusercontent.com/u/327458?v=4)](https://github.com/eduBKR "eduBKR (1 commits)")

---

Tags

credit-cardcredit-card-validationcreditcardluhn-algorithm

### Embed Badge

![Health badge](/badges/creditcard-identifier/health.svg)

```
[![Health](https://phpackages.com/badges/creditcard-identifier/health.svg)](https://phpackages.com/packages/creditcard-identifier)
```

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
