npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trid-iban

v0.1.0

Published

Lightweight Turkish IBAN validation library with MOD-97 checksum verification and bank identification

Readme

trid-iban

Lightweight Turkish IBAN validation library with MOD-97 checksum verification and bank identification.

Installation

npm install trid-iban

Usage

import { validateIBAN } from 'trid-iban';

validateIBAN('TR330006100519786457841326');          // true
validateIBAN('TR33 0006 1005 1978 6457 8413 26');   // true (spaces OK)
validateIBAN('TR000006100519786457841326');          // false

Detailed Validation

import { validateIBANDetailed } from 'trid-iban';

const result = validateIBANDetailed('TR330006100519786457841326');
// {
//   isValid: true,
//   errors: [],
//   bankCode: '00061',
//   bankName: undefined,       // undefined if bank code not in registry
//   formatted: 'TR33 0006 1005 1978 6457 8413 26'
// }

Formatting & Utilities

import { formatIBAN, cleanIBAN, extractBankCode, lookupBankName } from 'trid-iban';

formatIBAN('TR330006100519786457841326');
// 'TR33 0006 1005 1978 6457 8413 26'

cleanIBAN('TR33 0006 1005 1978 6457 8413 26');
// 'TR330006100519786457841326'

extractBankCode('TR330006100519786457841326');
// '00061'

lookupBankName('00046');
// 'Akbank'

API

validateIBAN(iban: string): boolean

Returns true if the given Turkish IBAN is valid. Accepts spaces, dashes, and dots (stripped automatically).

validateIBANDetailed(iban: string): IBANValidationResult

Returns detailed validation result with error information, bank identification, and formatted output.

interface IBANValidationResult {
  isValid: boolean;
  errors: IBANValidationError[];
  bankName?: string;    // Bank name (if known)
  bankCode?: string;    // 5-digit bank code
  formatted?: string;   // Formatted IBAN with spaces
}

formatIBAN(iban: string): string

Formats an IBAN into groups of 4 characters for readability.

cleanIBAN(iban: string): string

Removes spaces, dashes, and dots. Converts to uppercase.

extractBankCode(iban: string): string | undefined

Extracts the 5-digit bank code from positions 5-9.

lookupBankName(bankCode: string): string | undefined

Returns the bank name for a given 5-digit code, or undefined if not in the registry.

Error Codes

| Code | Description | |------|-------------| | EMPTY_INPUT | Input is empty or undefined | | INVALID_LENGTH | Input is not 26 characters | | INVALID_COUNTRY_CODE | Input does not start with "TR" | | INVALID_CHARACTER | Input contains non-digit characters after country code | | INVALID_CHECKSUM | MOD-97 checksum verification failed |

Algorithm

Turkish IBAN validation follows the ISO 13616 standard:

  1. Must be exactly 26 characters
  2. Must start with "TR"
  3. Characters 3–26 must all be digits
  4. MOD-97 check: Move first 4 characters to end → convert letters to numbers (A=10...Z=35) → result MOD 97 must equal 1

License

MIT