NPI numbers identify every healthcare provider in the United States. They’re ten digits long, and the tenth is a Luhn check digit computed over the 80840-prefixed base, per the CMS NPI Check Digit specification.

Most intake and import pipelines I’ve seen either skip this check entirely (and pay for it later in NPPES round-trips on garbage rows) or reinvent it badly inline. This is a single static class plus a CLI that does it correctly, with full xUnit coverage including the CMS spec’s worked example.

$ npivalidate 1234567893 1234567890 1003000118
 1234567893 VALID
 1234567890 INVALID
 1003000118 VALID

Exit code is 0 only if every input passed, so it slots into shell pipelines (cut, awk, xsv, etc.) and CI gates without ceremony.

  • C# / .NET 10, MIT-licensed, xUnit test suite.
  • Library use: NpiValidator.IsValid("1234567893") returns bool; ComputeCheckDigit("123456789") returns char. Pure static, no I/O, safe on hot paths.
  • PHI-aware: never logs, never persists, never transmits; every value lives in-process and exits via stdout only. NPIs are public identifiers, but they’re nearly always carried alongside PHI in real-world inputs.