U.S. banks are free to use any numbering system they want for their accounts. However, if those accounts are going to send and receive electronic payments, then the number cannot be more than 17 digits long. That limit comes from the Automated Clearing House, the computer network that handles transactions such as direct deposits and direct-debited bill payments. The ACH software accepts account numbers only up to 17 digits, so that's the limit for "ACH-enabled" accounts.
Bank Routing Numbers
Although bank account numbers are not standardized, the routing numbers that identify the banks themselves follow a set formula. This ensures that transactions get submitted to the correct banks; from there, the bank applies the transaction to the specified account. Routing numbers are always nine digits long. The first two digits indicate the Federal Reserve district where the bank is located. There are 12 districts: Boston, 01; New York, 02; Philadelphia, 03; Cleveland, 04; Richmond, Va., 05; Atlanta, 06; Chicago, 07; St. Louis, 08; Minneapolis, 09; Kansas City, Mo., 10; Dallas, 11; and San Francisco, 12. If the "bank" is actually a thrift, such as a credit union or savings and loan, the first digit will be increased by 2 -- so 22 would be a thrift in the New York district, and 32 would be a thrift in the San Francisco district.
In Europe, where payments cross national borders regularly, countries have adopted a standard format for account information, the International Bank Account Number. Each IBAN begins with a two-letter country code, such as FR for France or BE for Belgium, followed by two "check digits" that are used to validate the account. Those characters are followed by as many as 30 digits that identify the specific bank and account. Each country decides for itself how many digits it will use and what those digits indicate. The country code then tells you how to interpret the digits.
Most countries in Europe use IBAN, and the format has spread to several other nations: Israel, Kazakhstan, Kuwait, Lebanon, Mauritius, Saudi Arabia and Tunisia. Most of the world's countries, including the United States, do not participate in the IBAN system, although the format is designed to allow global implementation.