
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
mt940js is a SWIFT mt940 bank statement format parser for javascript (ES2015). Takes in text of mt940 file, puts out array of parsed statements and transactions. See examples below.
npm install mt940js
Main parser class - Parser - parses input text (e.g. read from a file) into array of statements (a file may contain one or more). Each output statement contains a set of attributes, describing opening balance, statement number, etc and also an array of transactions.
Example
const mt940js = require('mt940js');
const parser = new mt940js.Parser();
const statements = parser.parse(fs.readFileSync('./some_path', 'utf8'));
for (let s of statements) {
console.log(s.number.statement, s.statementDate);
for (let t of s.transactions) {
console.log(t.amount, t.currency);
}
}
Statement
transactionReference {string} - tag 20 referencerelatedReference {string} - tag 21 reference, optionalaccountIdentification {string} - tag 25 own bank account identificationnumber.statement {string} - tag 28 main statement numbernumber.sequence {string} - tag 28 statement sub number (sequence), optionalnumber.section {string} - tag 28 statement sub sub number (present on some banks), optionalopeningBalanceDate {Date} - tag 60 statement opening dateclosingBalanceDate {Date} - tag 62 statement closing dateclosingAvailableBalanceDate {Date} - tag 64 closing available balance date, default = closing dateforwardAvailableBalanceDate {Date} - tag 65 forward available balance date, default = closing available datestatementDate {Date} - abstraction for statement date = closingBalanceDatecurrency {string} - statement currency (USD, EUR ...)openingBalance {Number} - beginning balance of the statement (with sign, based on debit/credit mark)closingBalance {Number} - ending balance of the statement (with sign, based on debit/credit mark)closingAvailableBalance {Number} - tag 64 closing available balance, default = closing balanceforwardAvailableBalance {Number} - tag 65 forward available balance, default = closing availabletransactions {array} - collection of transactionsEach Transaction contains data of tag 61 (and tag 86 for details)
date {Date} - transaction dateamount {Number} - transaction amount (with sign, Credit+, Debit-)reversal {Boolean} - transaction is a reversalcurrency {string} - transaction currency (copy of statement currency)details {string} - content of relevant 86 tag(s), may be multiline (\n separated)transactionType {string} - MT940 transaction type code (e.g. NTRF ...)reference {string} - payment reference fieldentryDate {Date} - entry date field, optionalfundsCode {string} - funds code field, optionalbankReference {string} - bank reference, optionalextraDetails {string} - extra details, optionalstructuredDetails {Object} - structured details if detected, in for of { subtag: value } e.g. { '20': '123456' }Each statement is validated for:
Invocation
The Parser has just one method - parse(data, withTags = false) - which will convert raw mt940 string to an array of statements described above. The optional withTags parameter would preserve parsed tags to an additional tags attribute of a statement (for any additional further analysis).
Support for field 86 structure
Currently the library supports the following tag formats:
'<sep>DD', where <sep> can be '>' or '?''/TAG/value', where TAG is 2 to 4 uppercase chars.Example:
'>20some details >30more data'
or
'/ORDP/Smith Corp'
The parser attempts to detect if field 86 contains tags like these and, if yes, adds structuredDetails attribute to a statement line. Tag digits are not interpreted as they are not standardized among different banks.
// let incoming file contain one line with 86 field:
// '>20some details>30more data'
const statements = ... // parsing here
for (let s of statements) {
for (let t of s.transactions) {
console.log(t.structuredDetails);
// { '20': 'some details',
// '30': 'more data' }
}
}
Contribution is welcomed :)
The code is licensed under Apache-2.0 License. Please see LICENSE for details.
Inspired by https://github.com/WoLpH/mt940
FAQs
javascript mt940 bank statement parser
The npm package mt940js receives a total of 2,996 weekly downloads. As such, mt940js popularity was classified as popular.
We found that mt940js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.