# ISIN Checker

Machine-readable twin of https://isin.tigzig.com. Everything on the page, written
for an agent that will not render it.

Free, no key, no sign-up, no rate limit to think about.

## What it does

Checks whether an ISIN is well formed: twelve characters, a two-letter country
code, an alphanumeric body, a numeric check digit, and a check digit that
actually satisfies ISO 6166.

When it fails, it names the specific problem rather than answering "invalid", and
prints the arithmetic so the answer can be verified rather than trusted.

## Using it

    https://isin.tigzig.com/?isin=US0378331005

The `isin` query parameter pre-fills and checks immediately, so it is the form to
use when handing someone a link to their own answer.

The input also accepts:

- a list, comma or newline separated, checked together with the fund name for each
- a fund name in words, which returns matching schemes and their ISINs

## What comes back for each case

| Input | Result |
|---|---|
| `US0378331005` | valid. Country code US resolved to United States |
| `US0378331006` | not valid. "It ends in 6 and for these first eleven characters it has to be 5", plus the corrected ISIN |
| `INF74KA1ZG6` | not valid. "This is 11 characters. An ISIN is always 12, so 1 character is missing" |
| `1S0378331005` | not valid. "The first two characters are the country code and must both be letters" |
| `US037833100X` | not valid. "The last character is the check digit and must be a number" |
| `INF204K01XI3` | valid, and resolved to Nippon India Large Cap Fund Direct Growth with its latest NAV |
| `INF204K01XI4` | not valid, plus every real Indian fund one character away |

Spaces, hyphens and lower case are normalised before checking, so
`us 0378 3310 05` is treated as one ISIN rather than four tokens.

## Did you mean

When a 12-character ISIN fails only on its check digit, at least one character is
wrong, so the candidate set is computable: change any single character, or swap
any adjacent pair, and keep whichever results still pass. That is roughly 450
variants tested locally, narrowing to about 33 for a typical Indian fund ISIN.

Those candidates are then checked against 38,000 mutual fund schemes to see which
are real. All surviving matches are shown rather than a single guess, because for
a typical typo several real funds are one character away and a confident single
answer would usually be wrong.

## The algorithm

1. Convert letters to numbers, A=10 through Z=35. Digits stay as they are.
2. Take the first eleven characters as one string of digits.
3. Starting from the right, double every second digit.
4. Sum all the digits of the result. A doubled 7 becomes 14, contributing 1+4=5.
5. The check digit is whatever takes that total to the next multiple of ten.

The complete twelve-character ISIN, including its check digit, sums to a multiple
of ten. That is the whole test.

### Worked example

Apple Inc is `US0378331005`. U is 30 and S is 28, so the first eleven characters
become `3028037833100`. Doubling every second digit from the right and summing the
digits gives 45. The next multiple of ten is 50, and 50 minus 45 is 5, which is
the check digit.

### In code

```python
def isin_check_digit(body):          # body = the first 11 characters
    digits = "".join(str(ord(c) - 55) if c.isalpha() else c for c in body.upper())
    total, double = 0, True          # rightmost body digit is doubled
    for ch in reversed(digits):
        d = int(ch) * (2 if double else 1)
        total += d - 9 if d > 9 else d
        double = not double
    return (10 - total % 10) % 10

def is_valid(isin):
    return (len(isin) == 12 and isin[:2].isalpha() and isin[2:11].isalnum()
            and isin[11].isdigit()
            and isin_check_digit(isin[:11]) == int(isin[11]))
```

Test it against a known-good ISIN and a deliberately broken one before trusting
it. A validator that accepts everything looks exactly like one that works.

## Indian ISIN notes

Indian mutual fund ISINs start `INF` rather than `IN` plus something. That is not
an error: `IN` is the country and `F` is the first character of the identifier,
which NSDL uses to mean a fund. Equities are usually `INE`.

A scheme can have two ISINs. The payout and reinvestment options of the same IDCW
scheme carry different identifiers, and they are two identifiers for one scheme
rather than two schemes.

Specialized Investment Fund ISINs are valid but return nothing from mutual fund
sources, because AMFI's mutual fund feed carries no SIF schemes. SIF data is
published separately at https://sif.tigzig.com

## What a passing check does and does not mean

A valid check digit means the ISIN is well formed. It does not mean the security
exists, is still listed, or is the one you wanted. The check digit catches typing
mistakes and nothing more.

The reverse also holds: a real, valid ISIN can be absent from any given database,
which is a different problem from being malformed. If a system reports an ISIN as
not found, checking here separates the two.

## Privacy

Validation runs entirely in the browser. A malformed ISIN is never transmitted.
Only a valid Indian fund ISIN is sent anywhere, and only to resolve which fund it
is.

## Related

- Indian mutual fund analytics: https://www.tigzig.com/mfpro
- Free NAV API, lookup by ISIN or scheme code: https://www.tigzig.com/apis
- SIF data: https://sif.tigzig.com
- Everything else: https://www.tigzig.com/llms.txt

Contact: amar@harolikar.com
