Luhn Algorithm Validator
Pricing
Pay per event
Luhn Algorithm Validator
Validate numbers using the Luhn checksum algorithm. Detects card brands (Visa, Mastercard, Amex, Discover, JCB, Diners Club, Maestro, UnionPay), IMEI, Canadian SINs, and other Luhn-validated IDs. Bulk validation with check digit correction.
Pricing
Pay per event
Rating
0.0
(0)
Developer
Stas Persiianenko
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
5 days ago
Last modified
Categories
Share
Validate numbers using the Luhn checksum algorithm (mod 10). Supports credit card numbers, IMEI numbers, Canadian Social Insurance Numbers (SINs), National Provider Identifiers (NPIs), and any other Luhn-validated ID format. Detects card brands (Visa, Mastercard, American Express, Discover, JCB, Diners Club, Maestro, UnionPay) automatically from prefix and length patterns.
What does Luhn Algorithm Validator do?
Luhn Algorithm Validator takes a list of numbers and validates each one against the Luhn checksum algorithm. For every number, it returns:
- Validity status — whether the number passes the Luhn check
- Check digit analysis — the actual check digit and the expected check digit (for invalid numbers)
- Card brand detection — identifies Visa, Mastercard, Amex, Discover, JCB, Diners Club, Maestro, and UnionPay based on IIN (Issuer Identification Number) prefix ranges
- Number type classification — detects payment cards, IMEI numbers, Canadian SINs, NPIs, and other Luhn-validated formats
- Automatic normalization — strips spaces, dashes, dots, and parentheses before validation
The Luhn algorithm is used worldwide to validate identification numbers including credit card numbers (ISO/IEC 7812), IMEI numbers for mobile devices, Canadian Social Insurance Numbers, US National Provider Identifiers, and many government-issued IDs.
Who is Luhn Algorithm Validator for?
- Fintech developers validating payment card numbers before processing transactions
- Data quality engineers cleaning and validating large datasets of card or ID numbers
- Fraud detection teams flagging numbers that fail Luhn checks as potentially fabricated
- E-commerce platforms verifying card number formats before calling payment gateways
- QA engineers generating and validating test card numbers for payment system testing
- Compliance teams auditing PII datasets for valid card and ID number formats
- Mobile device management teams validating IMEI numbers in bulk
Why use Luhn Algorithm Validator?
- Zero cost per run — pure computation, no HTTP calls, no proxy, no browser. Runs in milliseconds
- Bulk processing — validate thousands of numbers in a single run
- Card brand detection — automatically identifies 8 major card networks from IIN prefix patterns
- Detailed diagnostics — for invalid numbers, shows the expected check digit so you can correct them
- Format-tolerant — handles numbers with spaces, dashes, dots, and parentheses
- API-ready — integrate into any pipeline via Apify API, webhooks, or MCP
What data does Luhn Algorithm Validator return?
| Field | Type | Description |
|---|---|---|
number | string | Original input as provided |
numberNormalized | string | Input with spaces, dashes, dots removed |
digitCount | number | Number of digits after normalization |
isValid | boolean | Whether the number passes the Luhn check |
checkDigit | number | Actual last digit of the number |
expectedCheckDigit | number | Correct check digit (useful for fixing invalid numbers) |
numberType | string | Detected type: Payment Card, IMEI, Canadian SIN, NPI, Other |
cardBrand | string | Card network: Visa, Mastercard, Amex, Discover, JCB, etc. |
cardBrandCode | string | Short code: VISA, MC, AMEX, DISC, JCB, DINERS, MAESTRO, UNIONPAY |
iinRange | string | IIN prefix range that matched (e.g., "4" for Visa, "51-55" for MC) |
error | string | Error message if input is malformed (non-digits, too short) |
How much does it cost to validate numbers with Luhn algorithm?
Luhn Algorithm Validator uses pay-per-event pricing. You only pay for what you use.
| Event | FREE tier | BRONZE | SILVER | GOLD | PLATINUM | DIAMOND |
|---|---|---|---|---|---|---|
| Run started (one-time) | $0.001 | $0.001 | $0.001 | $0.001 | $0.001 | $0.001 |
| Per number validated | $0.000345 | $0.0003 | $0.000234 | $0.00018 | $0.00012 | $0.000084 |
Example costs (BRONZE tier):
- 10 numbers: $0.001 + $0.003 = $0.004
- 100 numbers: $0.001 + $0.03 = $0.031
- 1,000 numbers: $0.001 + $0.30 = $0.301
- 10,000 numbers: $0.001 + $3.00 = $3.001
Free plan estimate: Apify's free tier gives you $5/month in platform credits. That's roughly 14,000 numbers per month at FREE tier pricing.
How to validate numbers with Luhn algorithm
- Go to Luhn Algorithm Validator on Apify Store
- Enter your numbers in the input field (one per line or as a JSON array)
- Click Start to run the validator
- View results in the Dataset tab — each number shows validity, check digit, and card brand
- Export results as JSON, CSV, or Excel, or connect via API
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
numbers | array | Yes | List of numbers to validate. Spaces, dashes, and dots are stripped automatically. |
Output example
{"number": "4532015112830366","numberNormalized": "4532015112830366","digitCount": 16,"isValid": true,"checkDigit": 6,"expectedCheckDigit": 6,"numberType": "Payment Card","cardBrand": "Visa","cardBrandCode": "VISA","iinRange": "4","error": null}
For invalid numbers, the output includes the expected check digit:
{"number": "4532015112830367","numberNormalized": "4532015112830367","digitCount": 16,"isValid": false,"checkDigit": 7,"expectedCheckDigit": 6,"numberType": "Payment Card","cardBrand": "Visa","cardBrandCode": "VISA","iinRange": "4","error": null}
Tips for best results
- Strip formatting first — the validator handles spaces, dashes, and dots, but other characters (letters, symbols) will cause an error
- Use check digit correction — when
isValidis false,expectedCheckDigittells you the correct last digit - Validate before payment calls — catching bad card numbers before hitting the payment gateway saves API fees and reduces declines
- Test card numbers — use standard test numbers like
4111111111111111(Visa),5500000000000004(Mastercard),340000000000009(Amex) - Batch for efficiency — send all numbers in a single run rather than one at a time, the start event is charged only once per run
Integrations
Luhn Algorithm Validator fits into data processing workflows:
- Payment form validation — validate card numbers client-side before submitting to Stripe/PayPal/Braintree
- ETL pipeline cleaning — validate a column of card/ID numbers in your data warehouse export, flag invalid rows
- Fraud detection pipeline — integrate as a pre-filter: numbers failing Luhn checks are likely fabricated
- QA test data generation — validate that your test card number generator produces Luhn-valid numbers
- Apify webhook chains — trigger Luhn validation automatically when another actor outputs card-like data
API usage
Node.js
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });const run = await client.actor('automation-lab/luhn-validator').call({numbers: ['4111111111111111', '5500000000000004', '1234567890'],});const { items } = await client.dataset(run.defaultDatasetId).listItems();console.log(items);
Python
from apify_client import ApifyClientclient = ApifyClient('YOUR_API_TOKEN')run = client.actor('automation-lab/luhn-validator').call(run_input={'numbers': ['4111111111111111', '5500000000000004', '1234567890'],})items = client.dataset(run['defaultDatasetId']).list_items().itemsprint(items)
cURL
curl "https://api.apify.com/v2/acts/automation-lab~luhn-validator/runs" \-X POST \-H "Content-Type: application/json" \-H "Authorization: Bearer YOUR_API_TOKEN" \-d '{"numbers": ["4111111111111111", "5500000000000004", "1234567890"]}'
MCP integration
Use Luhn Algorithm Validator directly from AI assistants via the Model Context Protocol (MCP).
Claude Code
$claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/luhn-validator"
Claude Desktop / Cursor / VS Code
Add to your MCP config file:
{"mcpServers": {"apify": {"url": "https://mcp.apify.com?tools=automation-lab/luhn-validator"}}}
Example prompts:
- "Validate these credit card numbers: 4111111111111111, 5500000000000004"
- "Check if 374245455400126 is a valid Amex number"
- "Which of these numbers pass the Luhn check?"
Supported card brands
| Brand | Prefix | Length | Code |
|---|---|---|---|
| Visa | 4 | 13, 16, 19 | VISA |
| Mastercard | 51-55, 2221-2720 | 16 | MC |
| American Express | 34, 37 | 15 | AMEX |
| Discover | 6011, 644-649, 65 | 16-19 | DISC |
| JCB | 3528-3589 | 16-19 | JCB |
| Diners Club | 300-305, 36, 38 | 14, 16, 19 | DINERS |
| Maestro | 5018, 5020, 5038, 6304, 6759-6763 | 12-19 | MAESTRO |
| UnionPay | 62 | 16-19 | UNIONPAY |
Legality and compliance
The Luhn algorithm is a mathematical checksum formula — it does not access any external services, databases, or APIs. This actor performs pure computation on the numbers you provide. No data leaves the Apify platform. No external requests are made. The algorithm itself is public domain (US Patent 2,950,048, expired 1977).
Important: This tool validates number FORMAT only (checksum correctness). A Luhn-valid number is not necessarily an active, issued, or authorized card. Never use Luhn validation as a substitute for payment authorization.
FAQ
What is the Luhn algorithm? The Luhn algorithm (also called the modulus 10 or mod 10 algorithm) is a checksum formula used to validate identification numbers. It was created by IBM scientist Hans Peter Luhn in 1954. It detects single-digit errors and most transpositions of adjacent digits.
Can this validator check if a credit card is real? No. The Luhn algorithm only verifies mathematical correctness of the check digit. A Luhn-valid number may be expired, cancelled, or never issued. Use a payment gateway for authorization checks.
Why does my number show as invalid?
Check these common causes: (1) the number has a typo in the last digit — compare checkDigit vs expectedCheckDigit, (2) the number contains letters or special characters that aren't stripped by normalization, (3) the number is too short (minimum 2 digits).
Does this work for non-card numbers like IMEI? Yes. The Luhn algorithm is the same regardless of number type. The validator also detects number types: IMEI (15 digits starting with 35), Canadian SIN (9 digits), NPI (10 digits), and payment cards (12-19 digits matching known IIN ranges).
How fast is the validation? Very fast — this is pure math with no HTTP requests. A batch of 10,000 numbers completes in under a second. Processing time is O(n) where n is the total number of digits across all input numbers.
Related tools
- Base64 Converter — encode and decode Base64 strings in bulk
- IBAN Validator — validate International Bank Account Numbers
- Email Validator — verify email address format and deliverability