Kontonummer

I maintain a library for client-side validation and formatting of Swedish bank account numbers called kontonummer. In this deep dive I summarise how Swedish bank account numbers are formatted and what rules they follow.

Sorting Code

Sorting codes are 4 digits long. (SSSS) However accounts in Swedbank that have a sorting code starting with 8 displays an extra 5’th check digit to the sorting code. (SSSS-C) The check digit is calculated using the mod-10 algorithm (1), (citation-needed) This means that in actual bank transactions the check digit is discarded for these accounts and only the first four “actually matter”. A sorting code needs to be a number between 1000 and 9999. (2)

The sorting code can be used to derive the account type (1 or 2) and the associated “comment” in a publication by Bankgirot. (3)

Account Number

Type 1

Type 1 accounts are the “standard” for Swedish bank accounts. Swedish bankers’ association are “actively working for increased standardisation on the Swedish market and only allows type 1 for new banks” (4)

A type 1 account number is 11 digits long, (4 digits for the sorting code and 7 for the account number) the sorting code and check digit is part of the account number. (3) The format is SSSSAAAAAAC, or with separation for readability SSSS AA AAA AC. (4, 5) Swedbank formats their type 1 account numbers in a different way SSSS-AA-AAAAC (6)

The check digit is calculated using a mod-11 algorithm which is either calculated on the whole sorting code and account number (SSSSAAAAAA) or, the last three digits of the sorting code and the whole account number (SSSAAAAAA) this varies by clearing number range and is referred to by “comment” in the documents from Bankgirot. (3, 7) Why does this differ? I have no idea!

Type 2

Type 2 accounts are the wild west of bank accounts. This is where you should go if you seek chaos.

Type 2 accounts are the older account type and the sorting code is not part of the account number. This means that the sorting code is often only required for external transactions, i.e. to another bank than the account holder’s. These accounts are mainly used by Handelsbanken, Nordea, Swedbank, and the independent savings banks. (4)

Type 2 account numbers are between 5 and 11 digits long without the sorting code (4), or 2-11 digits long if PlusGirot numbers are counted. (3) Worthy of note however is that PlusGirot “transaction accounts” are 10 digits long. This is mainly a different way of writing a PlusGirot account number. (8)

Some notable examples follow, for a full list see Bankgirot. (3)

Swedbank and the independent savings banks

Accounts with Swedbank and all the independent savings banks that have a sorting code starting with 8 are type 2 accounts. The sorting code is not part of the account number. As mentioned above, a 5’th digit is added to the sorting code for these Swedbank and independent savings banks’ bank accounts to account for that. The account number (check digit included) is 10 digits long. (3, 6)

The format for these account numbers is AAAAAAAAAC, or with separation for readability AAA AAA AAA-C when showing the sorting code in the latter format it is separated from the account number by a comma by Swedbank SSSS-C, AAA AAA AAA-C. (6)

The check digit are calculated using a mod-10 algorithm on the whole account number AAAAAAAAA. (3)

!!NOTE!! There exist very old Swedbank accounts without any check digit. There is no way to validate these account numbers. (3) According to Swedbanks phone support these accounts also “lives” under the same sorting codes as other accounts with a check digit and they can have either a 4-digit or a 5-digit sorting code, so there is no way to distinguish them. (9)

Handelsbanken

Accounts with Handelsbanken are 8 or 9 digits long. (3, 10)

The format for these account numbers are AAAAAAAAC, or with separation for readability AAA AAA AAC. As the sorting code is not part of the account number and not part of the check digit calculation. Account numbers that are shorter than 9 digits do not need to be zero-padded because the sorting code is not part of the account number and should be entered separately, so AA AAA AAC is valid. The sorting code is separated from the account number using a dash in their mobile applications SSSS - AAA AAA AAC, but it seems reasonable to use a comma like Swedbank to separate sorting code and account number. (citation-needed)

The check digit are calculated using a mod-11 algorithm on the whole account number AAAAAAAA. (3)

Nordea Personkonto

These accounts have the holders personal identity number as their account number. They are 10 digits long. Traditionally these account numbers are written without their sorting code, but in actuality they have the sorting code 3300. (3, 11)

No new Nordea Personkonto with the holders personal identity number as the account number are issued as of 2019-01-01. (11)

The format for these account numbers are AAAAAAAAAC. (3) It stands to reason that the format with separation for readability is the same as for a personal identity number AAAAAA-AAAC but do note that only digits are significant in bank account numbers so the dash (or plus for people older than 100) cannot be used to differentiate bank accounts which may men there is a risk for collisions. (citation-needed)

The check digit are calculated using a mod-10 algorithm on the whole account number AAAAAAAAA. (3) Same as for personal identity numbers. (12)

Nordea PlusGirot Account

TODO. There are some decisions to be made regarding this for the kontonummer library. Should the 2-8 digit format be allowed for validation or only the 10 digit longer form. this depends on Bankgirot implementation I think. Currently the 2-8 digit numbers do validate and the 10 digit ones do not.

Others

The other type 2 accounts are 10 digits long. (3)

The format for these account numbers are AAAAAAAAAC. (3) The format with separation for readability is not known at the time of writing (citation-needed)

The check digit are calculated using a mod-10 algorithm on the whole account number AAAAAAAAA. (3)

BankGirot and PlusGirot

Bankgirot is just an “address” to an actual account number whereas PlusGirot (formerly PostGirot) is an actual account.

TODO How to handle these in the kontonummer library? Should there be a separate Kontonummer.BgPg class with a different API? Open for suggestions.

PlusGirot

The format for these are AAAAAAAC, or with separation for readability AAA AA AA-C. (8) omit digits from the left if the number is shorter.

The check digit are calculated using a mod-10 algorithm on the whole account number AAAAAAA. (3)

Bankgirot

The format for these are AAAAAAAC or AAAAAAC, or with separation for readability AAAA-AAAC / AAA-AAAC. (1)

The check digit are calculated using a mod-10 algorithm on the whole number AAAAAAA. (1)

BIC (SWIFT) and IBAN

TODO: research + implement.

Im imagining a readonly bic: string property and a .format('iban').

Swedish IBAN numbers are 24 digits long and has the format [SE]KK BBBA AAAA AAAA AAAA AAAA (letters wrapped in [] are “escaped” i.e static and not a placeholder) (13)

The bank codes and BIC codes are assigned by the swedish bankers’ association. (14)

The check digits are calculated using a mod-97 algorithm. (13)

Needs further research

  1. https://www.dbschenker.com/se-sv/haer-ser-du-hur-kontonumret-ska-skrivas-foer-olika-banker-481736 Claims about Danske Bank
  2. PlusGirot vs PlusGirot Account (2-8 vs 14 digits)
  3. BIC/IBAN

Sources

  1. 1.
    Beräkning av kontrollsiffra 10-modulen [online]. 1 December 2016. Bankgirocentralen BGC AB. Retrieved from: [pdf], [archived], index
  2. 2.
    Förteckning över av Bankföreningen tilldelade och reserverade clearingnummerserier [online]. 12 June 2019. Svenska Bankföreningen. Retrieved from: [pdf], [archived], index
  3. 3.
    Bankernas kontonummer [online]. 21 August 2020. Bankgirocentralen BGC AB. Retrieved from: [pdf], [archived], index
  4. 4.
    Clearingnummer [online]. 19 February 2019. Svenska Bankföreningen. [Accessed 12 April 2020]. Retrieved from: [web], [archived]
  5. 5.
    Bankkonto [online]. 28 May 2019. Wikipedia. Retrieved from: [permalink]
  6. 6.
    Clearingnummer [online]. Swedbank. [Accessed 12 April 2020]. Retrieved from: [web], [archived]
  7. 7.
    Beräkning av kontrollsiffra 11-modulen [online]. 1 December 2016. Bankgirocentralen BGC AB. Retrieved from: [pdf], [archived], index
  8. 8.
    Transaktionskonto med PlusGironummer [online]. Nordea. [Accessed 12 April 2020]. Retrieved from: [web], [archived]
  9. 9.
    BENGTSON, Svante. Call with Swedbank regarding unverifiable account numbers. 17 April 2020.
  10. 10.
    VERA B, Svante Bengtson. Handelsbanken Chat: Question regarding length of account numbers in [online]. 17 April 2020. Handelsbanken. Retrieved from: [web], [archived]
  11. 11.
    Frågor och svar konton och clearingnummer [online]. Nordea. [Accessed 12 April 2020]. Retrieved from: [web], [archived]
  12. 12.
    SCB, avdelningen för befolkning och välfärd. Befolknings- och välfärdsstatistik 2016:1, Personnummer. [online]. 2006. P. 30. DOI doi:urn:nbn:se:scb-2016-be96br1601_pdf. Retrieved from: [pdf], [archived], index
  13. 13.
    International Bank Account Number [online]. 11 April 2020. Wikipedia. Retrieved from: [permalink]
  14. 14.
    Swedish Bank ID Codes for IBAN [online]. 23 May 2019. Svenska Bankföreningen. Retrieved from: [pdf], [archived], index
by Svante Bengtson