How to Check if an IMEI Is Valid (Luhn Algorithm Explained)
Learn how to check whether a 15-digit IMEI is valid using the Luhn algorithm — with a step-by-step guide and a fully worked example.
You have a 15-digit IMEI in front of you. Maybe a customer typed it into a form, maybe it came from a used-phone listing, maybe your test suite just produced it. Before you trust it, one question matters: is it actually valid?
"Valid" has a precise meaning here. It does not mean the device is real, unlocked, or off the blacklist — it means the number is structurally correct: exactly 15 digits, in the right format, with a check digit that passes the Luhn algorithm. That is the first gate every IMEI must clear, and you can test it in seconds.
This guide shows you exactly how to check if an IMEI is valid — by hand, with the math fully worked out, and with the instant IMEI validator when you just need an answer.
What "Valid" Actually Means
An IMEI passes validation when it satisfies three conditions:
- Length — it is exactly 15 digits (some systems also accept the 16-digit IMEISV variant).
- Characters — every character is a digit
0–9. No letters, spaces, or symbols once cleaned. - Checksum — the final digit (digit 15) matches the value the Luhn algorithm computes from the first 14 digits.
That third condition is the interesting one. The check digit is not chosen freely — it is derived from the other digits so that the whole number passes a specific math test. Get one digit wrong while copying an IMEI and the checksum almost always fails, which is exactly what it was designed to catch.
Important: a valid IMEI is not the same as a legitimate device. A number can be perfectly Luhn-valid yet belong to no real phone, or belong to a phone that is blacklisted. Validation checks format, not status. For status, see our IMEI blacklist check guide.
The Fastest Way: Use a Validator
If you just need a yes-or-no answer, skip the math:
- Open the IMEI validator.
- Paste the 15-digit number (spaces and dashes are stripped automatically).
- Read the result — valid or invalid — along with a breakdown of the TAC, serial number, and check digit.
This is the right approach for one-off checks and for non-technical users. But understanding how the check works makes you far better at spotting bad data, so let us walk through the algorithm.
The Luhn Algorithm, Step by Step
The Luhn algorithm (also called mod 10) was patented in 1960 and is used to validate credit-card numbers, IMEIs, and many other identifiers. Here is the procedure for a 15-digit IMEI.
Step 1 — Take the first 14 digits
The 15th digit is the check digit; you will compare against it at the end. Work with digits 1 through 14.
Step 2 — Double every second digit
Starting from the rightmost of those 14 digits and moving left, double every second digit. (Equivalently, double the digits in even positions counting from the left.)
Step 3 — Reduce two-digit results
If doubling produces a number greater than 9, subtract 9 (or add the two digits together — same result). So 12 becomes 3, 16 becomes 7, 10 becomes 1.
Step 4 — Sum everything
Add all the processed digits together: the doubled-and-reduced ones plus the untouched ones.
Step 5 — Compute the check digit
Find the next multiple of 10 at or above your sum, then subtract the sum. That result is the expected check digit. If it equals the 15th digit of your IMEI, the number is valid. If the running total is already a multiple of 10, the check digit is 0.
A Fully Worked Example
Let us validate the IMEI 35 824011 345678 4. The first 14 digits are:
3 5 8 2 4 0 1 1 3 4 5 6 7 8
Double every second digit (the digits in positions 2, 4, 6, 8, 10, 12, 14 from the left — 5, 2, 0, 1, 4, 6, 8):
| Original | Doubled | Reduced |
|---|---|---|
| 5 | 10 | 1 |
| 2 | 4 | 4 |
| 0 | 0 | 0 |
| 1 | 2 | 2 |
| 4 | 8 | 8 |
| 6 | 12 | 3 |
| 8 | 16 | 7 |
Now interleave them with the untouched odd-position digits (3, 8, 4, 1, 3, 5, 7), keeping every digit in its original position:
3, 1, 8, 4, 4, 0, 1, 2, 3, 8, 5, 3, 7, 7
Sum: 3 + 1 + 8 + 4 + 4 + 0 + 1 + 2 + 3 + 8 + 5 + 3 + 7 + 7 = 56.
Check digit: the next multiple of 10 at or above 56 is 60, so 60 − 56 = 4.
The computed check digit is 4, and the 15th digit of our IMEI is also 4. They match, so 358240113456784 is a valid IMEI. (This is the same walkthrough the calculator on the homepage performs server-side for every number it generates.)
Common Reasons an IMEI Fails Validation
When a check fails, it is almost always one of these:
- Transcription error — a single mistyped or transposed digit. This is exactly what Luhn is built to catch.
- Wrong length — 14 digits (missing one) or 16 digits (an IMEISV with the software-version suffix, or an extra character).
- Hidden characters — a stray space, dash, or non-breaking space pasted from a spreadsheet. Always strip non-digits first.
- Not an IMEI at all — a serial number, MEID, or random string that was mistaken for an IMEI.
- Placeholder data — sequences like
123456789012345or000000000000000that were never meant to be real.
Checking IMEIs at Scale
Validating one number is easy. Validating thousands — in a QA pipeline, a fraud-screening job, or a data-cleaning script — calls for automation. The logic is small enough to implement in any language. Here is the core Luhn check in JavaScript:
function isValidImei(imei) {
const digits = String(imei).replace(/\D/g, '');
if (digits.length !== 15) return false;
let sum = 0;
for (let i = 0; i < 15; i++) {
let d = Number(digits[i]);
// double every second digit from the right
if ((15 - i) % 2 === 0) {
d *= 2;
if (d > 9) d -= 9;
}
sum += d;
}
return sum % 10 === 0;
}
Note the neat property: if you include the check digit in the sum and the total is divisible by 10, the IMEI is valid. That is the same rule, expressed in one line.
If you need a steady supply of structurally valid IMEIs to feed those tests — numbers that pass this exact check and carry realistic TAC prefixes — generate them in bulk on the Random IMEI homepage and export straight to CSV.
Validate vs. Generate: Two Sides of One Coin
It is worth being clear about the difference:
- Validating answers "is this existing number well-formed?" Use the IMEI validator.
- Generating produces new, valid numbers for testing. Use the generator.
QA teams use both: generate a batch of valid IMEIs as test fixtures, then confirm your application validates them correctly (and rejects the broken ones you crafted on purpose).
FAQ
How do I check if an IMEI is valid?
Confirm it is exactly 15 digits, contains only numbers, and that the final digit matches the Luhn checksum of the first 14. The quickest method is to paste it into the IMEI validator, which performs all three checks instantly.
What is the Luhn algorithm?
The Luhn algorithm (mod 10) is a checksum formula that detects accidental errors in identification numbers. For IMEIs it verifies that the 15th digit is mathematically consistent with the other 14, catching most single-digit typos and transpositions.
Does a valid IMEI mean the phone is genuine?
No. Validation only confirms the number's format is correct. A Luhn-valid IMEI can still belong to no real device or to a blacklisted one. To check device status, use a carrier or a dedicated blacklist service rather than a format validator.
Why does my IMEI fail validation?
The most common causes are a mistyped digit, the wrong length (14 or 16 instead of 15), or hidden spaces and dashes copied from another app. Strip everything except digits and re-check the length first.
Can I validate an IMEI offline?
Yes. The Luhn check is simple arithmetic that needs no internet connection or database. You can compute it by hand, in a spreadsheet, or with a few lines of code like the example above.
Is a 14-digit number ever a valid IMEI?
No. A standard IMEI is 15 digits. A 14-digit value is missing its check digit (it may be just the TAC plus serial). The 16-digit IMEISV is a separate variant that replaces the check digit with a 2-digit software version number.
Where can I get valid IMEIs for testing?
Generate them. The Random IMEI generator builds 15-digit numbers with authentic TAC prefixes and correct Luhn check digits, so every output passes the validation described in this article.
Try our tools
Generate valid random IMEI numbers or validate existing ones instantly.
Related Articles
Bulk IMEI Generator: Generate Thousands of Test IMEIs for QA & Automation
Generate thousands of valid IMEI numbers at once for QA automation, database seeding, load testing, and mobile app development. Free bulk IMEI tool guide.
IMEI Blacklist Check: How to Verify a Phone Isn't Stolen Before Buying
Learn how to check if a phone's IMEI is blacklisted before buying it used, how IMEI blacklists work, and what gets a phone blocked.
iPhone IMEI Generator: Apple TAC Codes & iOS Testing
Generate valid iPhone IMEIs for iPhone 15, 14, 13 and 12 app testing, MDM development and iOS QA with Apple TAC and Luhn context.