@sv-v2/mtparser
v1.0.9
Published
Lightweight SWIFT MT940 / MT942 bank statement parser
Readme
@sv-v2/mtparser
A lightweight, zero-dependency SWIFT MT940 and MT942 bank statement parser for Node.js.
This lightweight parser extracts raw SWIFT MT940 and MT942 statement text into structured, easy-to-use JavaScript objects. It natively understands the field tags used in standard bank statement responses.
Installation
Install the package via npm:
npm install @sv-v2/mtparserUsage
Import the parser and pass your raw MT940/MT942 string data into the parse function. It will return an array of statement objects, grouping the data by each :20: block.
const mtparser = require('@sv-v2/mtparser');
// Your raw MT940/MT942 text
const rawStatementData = `
:20:TRX123456
:25:ACCOUNT-9999
:60F:C230819SAR15000,00
:61:2308190819C1000,00NTRFREF//BANKREF
:86:Payment from Client
:62F:C230819SAR16000,00
`;
// Parse the data
const statements = mtparser.mtParse(rawStatementData);
console.log(JSON.stringify(statements, null, 2));Supported Tags
The parser accurately extracts and maps the following SWIFT tags:
- :20: Transaction Reference Number
- :21: Related Reference
- :25: Account Identification
- :28 / :28C: Statement Number / Sequence Number
- :60F / :60M: Opening Balance
- :61: Statement Line (Transactions)
- :86: Information to Account Owner (Transaction Details)
- :62F / :62M: Closing Balance (Booked Funds)
- :64: Closing Available Balance
- :65: Forward Available Balance
