
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
swiftmessageparser
Advanced tools
SWIFT bank statement parser for JavaScript (ES2015). Supports MT 940 Customer Statement Message and MT 942 Interim Transaction Report.
npm install swiftmessageparser
const parser = require('swiftmessageparser');
const statements = parser.parse({
type: 'mt940',
data: fs.readFileSync(path, 'utf8'),
});
statements.forEach(stmt => {
console.log(stmt.statementDate, stmt.accountIdentification, stmt.number.statement);
stmt.transactions.forEach(txn => {
console.log(txn.amount, txn.currency);
};
};
This package also includes a CLI which parses a SWIFT file and outputs the result as JSON:
swift-parse -t mt942 my-statement.txt
Parse a SWIFT statement document.
If parser.parse() is invoked with { validate: true } then MT940 statements
are additionally validated for:
Returns: Array<Statement>
Params:
| Param | Type | Description |
|---|---|---|
| data | string | raw SWIFT message text |
| type | string | message format (mt940 or mt942) |
| validate | boolean | Optional perform additional semantic error checking |
| Field | Type | Description |
|---|---|---|
| transactionReference | string | tag 20 reference |
| relatedReference | string | tag 21 reference |
| accountIdentification | string | tag 25 own bank account identification |
| number.statement | string | tag 28 main statement number |
| number.sequence | string | tag 28 statement sub number (sequence) |
| number.section | string | tag 28 statement sub sub number (present on some banks) |
| statementDate | Date | tag 62 (MT940, day precision) or tag 13D (MT942, minute precision) |
| openingBalanceDate | Date | tag 60 statement opening date |
| closingBalanceDate | Date | tag 62 statement closing date |
| closingAvailableBalanceDate | Date | tag 64 closing available balance date, default = closing date |
| forwardAvailableBalanceDate | Date | tag 65 forward available balance date, default = closing available date |
| currency | string | statement currency (USD, EUR ...) |
| openingBalance | BigNumber | beginning balance of the statement (with sign, based on debit/credit mark) |
| closingBalance | BigNumber | ending balance of the statement (with sign, based on debit/credit mark) |
| closingAvailableBalance | BigNumber | tag 64 closing available balance, default = closing balance |
| forwardAvailableBalance | BigNumber | tag 65 forward available balance, default = closing available |
| informationToAccountOwner | string | additional statement level information |
| transactions | array | collection of transactions |
| messageBlocks | object | statement message blocks, if present (EXPERIMENTAL) |
| Field | Type | Description |
|---|---|---|
| date | Date | transaction date |
| amount | BigNumber | transaction amount (with sign, Credit+, Debit-) |
| reversal | Boolean | transaction is a reversal |
| currency | 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 field |
| entryDate | Date | entry date field |
| fundsCode | string | funds code field |
| bankReference | string | bank reference |
| extraDetails | string | extra details (supplementary details) |
| structuredDetails | Object | structured details if detected |
| nonSwift | string | content of NS tags associated with a transaction (after tags 61 or 86) |
The transaction.structuredDetails attribute can be used to access structured
data from statement transaction details (SWIFT "86" tag). The following
structured detail formats are supported:
'<sep>DD', where <sep> can be '>' or '?' and DD is two digits'/TAG/value', where TAG is 2 to 4 uppercase chars.Example
>20some details >30more data
{
"20": "some details",
"30": "more data"
}
Example
/ORDP/Smith Corp
{
"ORDP": "Smith Corp"
}
See Changelog
Copyright © 2015 Alexander Tsybulsky and other contributors. Copyright © 2020 Centrapay.
This software is licensed under Apache-2.0 License. Please see LICENSE for details.
Forked from a-fas/mt940. Originally inspired by WoLpH/mt940.
FAQs
Swift financial message parser (MT940, MT942)
The npm package swiftmessageparser receives a total of 206 weekly downloads. As such, swiftmessageparser popularity was classified as not popular.
We found that swiftmessageparser 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.