ForHosting KIT · Developer Utilities

Portuguese NIB check digits

For the body 0002 0123 12345678901 the check digits are 54, so the full NIB reads 0002.0123.12345678901.54. Enter the nineteen digits to get the pair, or paste a complete NIB to confirm it before a transfer or salary file goes out. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Nib
0002012312345678901
Calculation mode
Compute
You get
Input
0002012312345678901
Bank
0002
Branch
0123
Account
12345678901

The Portuguese NIB (Número de Identificação Bancária) is the twenty-one-digit national bank account identifier used on transfers, salary files, direct debits, and many Portuguese payment forms. It is built from a four-digit bank code, a four-digit branch code, an eleven-digit account number, and two trailing check digits.

What a Portuguese NIB is and how ISO 7064 MOD 97-10 applies

A Portuguese NIB identifies a domestic bank account in national payment rails and in many business systems that still store the twenty-one-digit form alongside or instead of the IBAN. Printed statements and forms often group the digits as four, four, eleven, and two with dots or spaces, but the underlying value is always twenty-one decimal digits.

The first four digits are the bank code assigned in the Portuguese banking system; the next four identify the branch or balcão; the following eleven digits are the account number as held by the bank; and the final two are check digits computed from the preceding nineteen. The official rule is ISO 7064 MOD 97-10: treat the nineteen-digit body as an integer, append two zeros, take that value modulo ninety-seven, and subtract the remainder from ninety-eight to obtain a two-digit check in the range zero-one through ninety-seven, zero-padded when needed.

Equivalently, a complete well-formed NIB satisfies the property that the full twenty-one-digit number modulo ninety-seven equals one. That modular identity is the same family of check used in IBAN construction, which is why Portuguese IBANs embed the NIB after the country code and IBAN check digits. Compared with Luhn mod-ten on payment cards or single-digit weight schemes such as Polish NIP, the NIB uses a two-digit MOD 97-10 residue over the entire body, so you must not reuse a Luhn validator on Portuguese account fields.

Compared with a generic ISO 7064 pure-system tool that only covers MOD 11-2 or MOD 37-2, this capability hard-codes the Portuguese NIB layout and the MOD 97-10 hybrid system used for bank accounts. Knowing which scheme you need avoids false confidence when a general check-digit utility accepts a digit string that is not a well-formed NIB. This tool implements the modular arithmetic on pure digits after optional space, dot, and hyphen stripping.

It does not query bank directories, prove that an account is open, or convert to IBAN by itself — only that the digit string is consistent under the published NIB check algorithm.

Where Portuguese NIB check digits fit payments, payroll, and onboarding

Domestic Portuguese transfers, SEPA setups that still collect a NIB, and many salary and supplier master records store the twenty-one-digit identifier; a single mistyped check digit during onboarding can send money to the wrong account or fail bank validation later. Fintech apps that build Portuguese IBANs from a NIB can call compute mode on the body and assert that the embedded check digits match the NIB they will place after the IBAN check.

Product teams that already expose general Luhn or pure-system ISO 7064 tools should still use this NIB-specific capability for Portuguese bank account fields so length bounds, MOD 97-10, and display formatting match the domain. Educational and SEO landings that rank for phrases such as portuguese nib check digits or portugal nib calculator need a live free tool whose browser path matches automation so tutorial screenshots stay accurate.

Do not treat a passing NIB check as proof that the account is open, belongs to the named customer, or is authorized for a transfer — it only proves the digit string is consistent under ISO 7064 MOD 97-10 for the Portuguese NIB layout.

Audit NIB columns in payroll and partner files

Batch-validate every NIB in a CSV import and quarantine rows whose check digits no longer match the recomputed expected pair under ISO 7064 MOD 97-10.

How are Portuguese NIB check digits calculated?

Take the 19-digit body (bank 4 + branch 4 + account 11), append 00, compute that number modulo 97, and set the two check digits to 98 minus the remainder, zero-padded to two digits (ISO 7064 MOD 97-10). A full 21-digit NIB is valid when the number modulo 97 equals 1.

What is the difference between compute and validate modes?

Compute takes 19 body digits (or bank, branch, and account) and returns the two check digits and full 21-digit NIB. Validate takes 21 digits including the check pair and returns whether they match the recomputed digits.

What are the parts of a Portuguese NIB?

It has twenty-one digits in four parts: a four-digit bank code, a four-digit branch code, an eleven-digit account number and two check digits. Statements often print the groups separated by dots or spaces.

Does a valid NIB prove that the account exists?

No. A valid result only means the digits agree with the official check. The tool does not search bank directories, confirm that the account is open or tell you who holds it.

How is the NIB related to a Portuguese IBAN?

A Portuguese IBAN carries the full NIB right after the country code and the two IBAN check digits. Both rely on the same modulo 97 family of checks, but this tool works on the NIB alone and does not build the IBAN.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/enc/nib-portugal

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/enc/nib-portugal \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"nib":"0002012312345678901","number":"valor-ejemplo"}'
{
  "nib": "0002012312345678901",
  "number": "valor-ejemplo"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "enc.nib_portugal",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Those two digits are not free text: they are completely determined by the ISO 7064 MOD 97-10 algorithm applied to the nineteen-digit body, so a single mistype almost always fails the modular check. This capability computes the correct two check digits from bank, branch, and account (or from a combined nineteen-digit body), or validates a full twenty-one-digit NIB that already includes them, and it reports bad input instead of inventing a result. Use it free in the browser or call the KIT API at the published price; both paths run the same deterministic arithmetic with no network lookup and no bank directory.

How to compute the two check digits or validate a full NIB

Send either a combined nib field or the structured bank, branch, and account fields. Digits zero through nine are required; optional spaces, dots, underscores, or hyphens are stripped before parsing. Mode validate expects a complete twenty-one-digit NIB including the trailing check pair (for example 000201231234567890154 or 0002.0123.12345678901.54). Empty strings, missing fields, invalid mode values, and wrong lengths fail before modular arithmetic runs and are not billed. Letters and other punctuation are rejected as malformed input with invalid_input so you never accept a silently cleaned value. Mode compute is the default: provide exactly nineteen body digits without the check digits (for example 0002012312345678901 or bank 0002, branch 0123, account 12345678901), and the engine returns check_digits as a two-character string, with_check as the full twenty-one-digit NIB, and formatted as the common XXXX.XXXX.XXXXXXXXXXX.XX display form, along with bank, branch, account, algorithm iso7064_mod97_10, and mod97_remainder of one on the completed number. The response reports valid true when the recomputed check digits match the last two digits and the full number is congruent to one modulo ninety-seven; it always includes expected_check_digits, payload without the check pair, and formatted for consistent display. Because the path is pure parse with no clock, random source, or network, the same input always yields the same JSON on the free browser tool and on the API. At $0.002 per successful request you can gate bulk payment imports, payroll files, and onboarding forms without negotiating a custom tier. Prefer compute when you assemble a NIB from known bank, branch, and account parts; prefer validate when a user, partner file, or scanned statement supplies a full number and you need a boolean gate before a transfer or master-data write.

Where Portuguese NIB check digits fit payments, payroll, and onboarding

Validate mode at entry blocks the save when valid is false and can show expected_check_digits so the clerk corrects the form before the record is written. Payroll and ERP imports receive partner NIBs from spreadsheets where a wrong trailing pair would reject a whole batch; a deterministic oracle that returns valid and with_check lets importers flag rows before they hit production.

Gate NIB fields on payment and supplier forms

When a user submits a full Portuguese NIB, call validate mode and block the save when valid is false, showing expected_check_digits to help correct a mistype before the payment master is written.

Compute the two check digits when assembling accounts

From bank, branch, and account (or a 19-digit body), call compute mode and store with_check or formatted so every new NIB carries the correct trailing pair before print, export, or transfer generation.

Are spaces, dots, and hyphens allowed?

Yes. Common separators are stripped before parsing. Letters and other punctuation are rejected with invalid_input.

What happens if the check digits are wrong?

In validate mode the response still includes expected_check_digits, and valid is false. Completely malformed input or wrong lengths fail with invalid_input.

What does the Portuguese NIB check digits calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →