Skip to main content

CCParser - Powerful Credit Card Parsing & Validation Library

PyPI
License
Build Status

CCParser is a robust and efficient Python library designed for seamless credit card parsing, validation, and formatting. It can extract card details from clean, delimited strings and messy real-world text while keeping a simple, consistent API.


Features

  • Smart extraction of card number, expiry date, and CVV from many formats
  • Heuristic parser for messy input (labels, mixed delimiters, extra text)
  • Parse-time CVV length validation (3 or 4 digits)
  • Luhn validation and expiry validation helpers
  • CVV validation with card-type awareness
  • Card type detection across 20 major networks
  • Formatting and masking helpers
  • CLI for quick parsing and validation

Disclaimer

This library is intended for educational and legitimate purposes only.

CCParser is designed to assist developers in:

  • Building payment processing systems
  • Testing and validating payment integrations
  • Educational purposes and learning about payment card industry standards
  • Fraud detection and prevention systems

Prohibited uses include:

  • Unauthorized access to financial systems or data
  • Credit card fraud, carding, or any form of financial crime
  • Harvesting, storing, or processing stolen card information
  • Any activity that violates applicable laws or regulations

By using this library, you agree to comply with all applicable laws, including but not limited to PCI-DSS standards, and take full responsibility for your use of this software. The author(s) are not responsible for any misuse or illegal activities conducted with this tool.

If you suspect fraudulent activity, please report it to your local authorities.


Supported Card Types

CCParser recognizes and validates card networks including:

  • AMEX
  • Dankort
  • Diners Club
  • Discover
  • Elo
  • Humo
  • InstaPayment
  • InterPayment
  • JCB
  • LankaPay
  • Maestro
  • MasterCard
  • Mir
  • Troy
  • UATP
  • UnionPay
  • UzCard
  • Verve
  • Visa
  • Visa Electron

Installation

pip install ccparser

Usage Examples

Supported Formats

CCParser supports a wide range of inputs, including:

4111111111111111|12/30|123
4111111111111111|12|2030|123
4111111111111111|12|30|123
4111111111111111 12 2030 123
4111111111111111 12 30 123
4111111111111111:12:2030:123
4111111111111111 2030/12 123
4111111111111111;12-30;123
4111 1111 1111 1111 12/30 123

CC #: 4111111111111111
Exp: 03/29
CVV: 123

Python API

from ccparser import CCParser

card = CCParser("4111111111111111|12|2030|123")
print(card.get_number())           # 4111111111111111
print(card.get_formatted_number()) # 4111 1111 1111 1111
print(card.get_expiry())           # 12/30
print(card.get_cvv())              # 123
print(card.is_valid())             # True
print(card.get_card_type())        # Visa
print(card.get_masked_number())    # **** **** **** 1111
print(card.get_year())             # 2030
print(card.get_month())            # 12

Card Number Generation

from ccparser.generator import generate_card_number

print(generate_card_number("Visa"))
print(generate_card_number("MasterCard"))

CLI

ccparser "4111111111111111|12|2030|123"
ccparser --masked "4111111111111111|12|2030|123"
ccparser --json "4111111111111111|12|2030|123"

License

This project is licensed under the MIT License - see the LICENSE file for details.


Contributing

Contributions are welcome! Please review our CONTRIBUTING.md guidelines before submitting a pull request.


Acknowledgements

  • Luhn Algorithm
  • Python regular expressions

Contact

For any inquiries or issues, feel free to reach out:

Vihanga Indusara - vihangadev@gmail.com


CCParser - Simplifying credit card parsing, one line at a time.

Metadata

Release files for CCParser 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CCParser 2.0.1
File Size Uploaded
ccparser-2.0.1.tar.gz 28.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CCParser 2.0.1
File Interpreter ABI Platform
ccparser-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 49.5 kB

Release files / ccparser-2.0.1.tar.gz

Download URL ccparser-2.0.1.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
614c7fe4530bd79f51f77e1a6cbe6061728eeef073bea0f6399d99c332f7c921
BLAKE2b-256 checksum
How to use checksums
1253b799435074ae0f48613595b1ed719f141bc32672d561a42f14542332502e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / ccparser-2.0.1-py3-none-any.whl

Download URL ccparser-2.0.1-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d72e00cb0e5c3fca74a1eba274dd296e600c3706333ea7a10e7f973a14485f0
BLAKE2b-256 checksum
How to use checksums
01ec4bd8b9a59817864a6ec2e17751517a1374f5788f94445c98c57a303c06f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.5.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page