An Israeli ID number is nine digits ending in a Luhn check digit. How it is calculated, why zero-padding breaks code, and why it is not identity proof.
Key takeaways
- The number is always nine digits. Shorter legacy numbers are zero-padded on the left, and that padding is what breaks almost every first implementation.
- Weights run 1,2,1,2,1,2,1,2,1 from left to right. Any product above 9 is replaced by the sum of its digits, which is the same as subtracting 9.
- A mathematically valid number can still belong to somebody else. A check digit is not identity verification.
- Israel's Privacy Protection Authority published an opinion stating that an ID number is information whose collection needs justification, and that less intrusive identification methods should be preferred.
- If the number is not needed at the first step of the process, do not ask for it on the lead form.
An Israeli ID number is nine digits, the last of which is a check digit computed with the Luhn method. Multiply the digits alternately by 1 and 2 from left to right, replace any two-digit product with the sum of its digits, and the total must be divisible by 10. The check catches typing mistakes. It does not identify a person.
How the check digit is calculated
The algorithm is a Luhn variant over nine digits, with the check digit itself included in the sum:
- Normalise the input to exactly nine digits, padding with zeros on the left.
- Walk the digits left to right, multiplying alternately by 1 and 2, starting with 1 on the first digit.
- If a product exceeds 9, subtract 9 from it. That is identical to summing its two digits.
- Add the nine results together.
- The number is valid if and only if the total is divisible by 10 with no remainder.
A synthetic example: 123456782. Its digits run in sequence, so it clearly does not belong to a real person.
| Digit | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 |
|---|---|---|---|---|---|---|---|---|---|
| Weight | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 |
| Product | 1 | 4 | 3 | 8 | 5 | 12 | 7 | 16 | 2 |
| After subtracting 9 | 1 | 4 | 3 | 8 | 5 | 3 | 7 | 7 | 2 |
The total is 40, which divides by 10, so the number passes. A single wrong digit, or two adjacent digits swapped, will almost always be caught.
Why is zero-padding the most common bug?
Because older ID numbers are shorter than nine digits, and interfaces display them without their leading zeros. A user types eight digits, the code runs over eight, the alternating weights start on the wrong position, and every short number is rejected as invalid.
- Normalise every input with
padStart(9, '0')before the calculation, not after it. - Strip spaces and hyphens before padding, not at the end of the pipeline.
- Always store the value at length nine, as a string. A numeric database column destroys the leading zero silently.
- Never compare ID strings across two systems without normalising both first. That is a classic source of duplicate customer records.
Does a valid number prove this is that person?
No, and that distinction is the whole point. The check digit tests internal mathematical consistency and nothing else. Anyone can generate nine digits that satisfy the calculation in seconds, and most real people's ID numbers satisfy it too - which is exactly the intent.
So the check has one legitimate use: reducing typing mistakes before a value enters a system. It is not suitable for opening an account, releasing information, identifying a caller, or any decision that affects a person. Those require verification against an external source, or a mechanism such as a one-time code sent to a pre-registered phone.
Where to run the check, and what to do with the result
| Location | What it gives you | What it does not |
|---|---|---|
| Browser | Immediate feedback before submit | Any guarantee; it can be bypassed |
| Server | The only check that counts | User experience; the error arrives late |
| Database | Normalisation and consistent length | Any notion of business correctness |
| External source | Real verification against a record | Anything without authorisation and a legal basis |
The simple rule is browser for convenience, server for truth. A validation failure on a lead form should be a soft warning that still lets the visitor submit, not a hard block - a form that rejects a lead over one digit deletes an enquiry sales would have closed on the phone.
Normalisation, duplicates and test data
The check itself is a small part of the work. Most of the trouble that shows up afterwards comes from the same number being stored in three different shapes across three systems.
- Normalise before comparing, never after: strip spaces and hyphens, then pad to nine digits. In that order and no other.
- Match on the normalised value when merging a lead into an existing customer. Matching on raw input creates two records for one person.
- Store the normalised value in a field separate from the original input. When somebody insists they typed it correctly, you can show what was actually submitted.
- Do not use the number as a primary key. People mistype it, and a primary key that changes breaks every relation hanging off it.
- For automated tests, generate valid synthetic numbers in code rather than copying real ones into a development environment.
That last point matters more than it sounds. A real ID number pasted into a fixture file eventually reaches git, log aggregators, and environments that were never meant to hold it.
What to collect, and what not to
Israel's Privacy Protection Authority published an opinion on collecting ID numbers and photographing ID cards, in which it notes that an ID number is a unique identifier acting as a key to further personal information, that it should only be collected where genuinely required, and that less intrusive identification methods should be preferred.
- Do not ask for an ID number at the lead stage if it is only needed at contract stage.
- If it is needed, say why on the form, in one sentence.
- Show a partially masked value on internal screens rather than the full number.
- Never put it in a query-string parameter, or in a request body that gets written to logs.
- Define a deletion policy. A lead that never became a customer should not hold an identifier forever.
This is a technical description of a validation mechanism and of a published official document, not legal advice. Binding requirements must be checked against the official source.
Related: form design that converts, automating lead routing, validating Israeli public vehicle data.
Sources
Frequently asked questions
Is the check-digit algorithm secret?
No. It is a well-known, published Luhn variant that appears in literature and in many public tools. It carries no information about the holder, and it makes generating valid numbers of real people no easier than any other check-digit formula does.
What should happen when a user types a number that fails?
Show a message that points at the field and lets them correct it, but do not block submission. On a lead form it is better to accept the enquiry flagged as "invalid number" and let a salesperson correct it on the call than to lose a prospect over a mistyped digit.
Can I use the same check for a company ח"פ number?
Not necessarily, and it is an assumption worth avoiding. Israeli corporate identifiers are a separate numbering space with their own rules. If your system accepts both sole traders and companies, you need an entity-type field and a separate check for each, not one formula for both.
Is it acceptable to store the number in the database?
That is a question of justification and minimisation, not of technical capability. The Privacy Protection Authority's opinion stresses collecting an ID number only where required. Technically, if you do store it, store it as a nine-character string, with restricted access and a defined deletion policy.
Keep reading
Related service
Lead Management
Catch every enquiry, route it, chase it, and see which source pays.
About the author
Yehonatan Saadia
Freelance automation, web & MVP developer
I'm Yehonatan Saadia, a senior developer who builds business automation, custom websites, and MVPs for small and mid-sized companies across the US, Europe, and Israel. These guides come from real client work, not theory.
Work with meHave a project like this?
Tell me what you're trying to automate or build. I reply within 24 business hours with a few targeted questions, then we walk through it on a free 30-minute call, with no commitment. You come away with a scope, a timeline and a fixed price - or a straight answer that it isn't worth building.
