| Author: | ContaAzul |
|---|---|
| Views Total: | 8,856 views |
| Official Page: | Go to website |
| Last Update: | November 25, 2025 |
| License: | MIT |
Preview:

Description:
credicard.js is a zero-dependency JavaScript library for validating credit card numbers, expiration dates, security codes, and returning the credit card brand.
Supports both browser and server.
Supported Credit Card Types:
- American Express
- Aura
- Banescard
- Cabal
- Diners
- Discover
- Elo
- Goodcard
- Hipercard
- Mastercard
- Maxxvan
- Visa
How to use it:
1. Install & import the credicard.js component.
# Yarn $ yarn add creditcard.js # NPM $ npm i creditcard.js
import {
isValid,
isExpirationDateValid,
isSecurityCodeValid,
getCreditCardNameByNumber
} from 'creditcard.js';2. Or include the credicard.js script on your webpage.
<script src="/dist/creditcard.min.js"></script> // OR From A CDN <script type="module"> import creditcardJs from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm' </script>
3. Validate a specified credit card number.
var creditcard = new CreditCard();
// return true
console.log(creditcard.isValid('4111111111111111'));
isValid('4916108926268679', { cards: ['visa', 'mastercard'] }) // returns true
isValid('4916108926268679', { cards: ['mastercard'] }) // returns false4. Validate the expiration date.
var creditcard = new CreditCard();
// return true
console.log(creditcard.isExpirationDateValid(''05', '2020''));5. Validate the security code.
var creditcard = new CreditCard();
// return true
console.log(creditcard.isSecurityCodeValid(''4111111111111111', '250''));6. Validate a specified credit card number and return the result in the console.log.
var creditcard = new CreditCard();
// return 'Visa'
console.log(creditcard.getCreditCardNameByNumber('4111111111111111'));Changelog:
v3.0.45 (11/25/2025)
- update packages
v3.0.44 (11/24/2025)
- update packages
v3.0.43 (09/18/2025)
- update packages
v3.0.41 (09/16/2025)
- update packages
v3.0.41 (09/15/2025)
- update packages
v3.0.40 (09/12/2025)
- update packages
v3.0.39 (09/11/2025)
- update packages
v3.0.36 (09/10/2025)
- update packages
v3.0.34 (04/14/2025)
- update packages
v3.0.33 (11/20/2023)
- update packages
v3.0.31 (10/19/2023)
- update packages
v3.0.30 (03/03/2023)
- update engines
v3.0.28/29 (02/22/2023)
- bugfixes
v3.0.22/27 (02/19/2023)
- updated package
v3.0.22/25 (02/08/2023)
- updated package
v3.0.22/23 (12/06/2022)
- updated package
v3.0.21 (11/11/2022)
- updated package
v3.0.19 (06/06/2022)
- updated package
v3.0.17 (05/09/2022)
- change the elo bin regex
v3.0.15 (03/30/2022)
- update devDependencies
v3.0.13 (10/07/2021)
- update devDependencies
v3.0.10 (06/02/2021)
- update devDependencies
v3.0.7 (05/13/2021)
- update devDependencies
v3.0.6 (03/23/2021)
- applying single responsability into isValid function
v3.0.5 (02/26/2021)
- IsValid card options
v3.0.3 (01/21/2021)
- Bug Fixes
v3.0.0 (01/18/2021)
- v3
v2.1.5 (05/25/2018)
- Update CREDIT_CARD_LIST to use literal regex







