Parsing MT940 & MT950 SWIFT using Prowide
13:18 30 Aug 2025

I’d like to process old SWIFT messages and in particular parse MT940 & MT950 message types.

A single file may contain multiple message types separated by a ‘$’.

I tried Prowide-core, but the output appears incomplete. Would you kindly help?

My sample.txt file

{1:F21CITIUS33AGFX7239256290}{4:{177:2507150853}{451:0}}{1:F01CITIUS33AGFX7239256290}{2:O9500153250715SBOSUS3UFIMS13447057842507150853N}{4:
:20:2507150000118899
:25:PFZM
:28C:138/1
:60F:C250714USD53944,66
:61:2507130714CD2725,28NSALSCTRSC000004FWHL//25GFKBBPF0P
/ISIN/US0001200901/SHS/12148,
:62F:C250714USD56669,94
:64:C250714USD56669,94
-}{5:{CHK:F0FC1309E8AB}}{S:{COP:P}{MDG:B7D497E702BC8EE8EDBFBCBDACF30DB07A7352E76BE40274B87FC17253462868}}%

My SwiftDemo.java code

import com.prowidesoftware.swift.io.parser.SwiftParser;
import com.prowidesoftware.swift.model.SwiftMessage;
public class SwiftDemo {

    public static void main(String[] args) throws Exception {
        String path = "sample.txt";
        String fin = java.nio.file.Files.readString(java.nio.file.Paths.get(path), java.nio.charset.StandardCharsets.UTF_8);

        SwiftParser parser = new SwiftParser(fin);
        SwiftMessage sm = parser.message();
        System.out.println(sm.toJson());
    }
}

The prowide-core result is:

{
  "timestamp": "2025-08-30T19:49:12Z",
  "version": 2,
  "data": {
    "block1": {
      "applicationId": "F",
      "serviceId": "21",
      "logicalTerminal": "CITIUS33AGFX",
      "sessionNumber": "7239",
      "sequenceNumber": "256290"
    },
    "block4": {
      "tags": [
        {
          "name": "177",
          "value": "2507150853"
        },
        {
          "name": "451",
          "value": "0"
        }
      ]
    }
  }
}

Whereas using swift-parser-py, when I run:

python -m swift_parser_py.swift_parser sample.txt

The swift_parser_py result is:

{
  "block1": {
    "block_id": 1,
    "content": "F01CITIUS33AGFX7239256290",
    "application_id": "F",
    "service_id": "01",
    "receiving_lt_id": "CITIUS33AGFX",
    "session_number": "7239",
    "sequence_number": "256290"
  },
  "block4": {
    "name": "4",
    "content": [
      "\n:20:2507150000118899\n:25:PFZM\n:28C:138/1\n:60F:C250714USD53944,66\n:61:2507130714CD2725,28NSALSCTRSC000004FWHL//25GFKBBPF0P\n/ISIN/US0001200901/SHS/12148,\n:62F:C250714USD56669,94\n:64:C250714USD56669,94\n-"
    ],
    "fields": [
      {
        "type": "20",
        "option": "",
        "fieldValue": "2507150000118899",
        "content": ":20:2507150000118899",
        "ast": {
          "Reference Number": "2507150000118899"
        }
      },
      {
        "type": "25",
        "option": "",
        "fieldValue": "PFZM",
        "content": ":25:PFZM",
        "ast": {
          "Account": "PFZM"
        }
      },
      {
        "type": "28",
        "option": "C",
        "fieldValue": "138/1",
        "content": ":28C:138/1",
        "ast": {
          "Statement Number": "138",
          "Sequence Number": "1"
        }
      },
      {
        "type": "60",
        "option": "F",
        "fieldValue": "C250714USD53944,66",
        "content": ":60F:C250714USD53944,66",
        "ast": {
          "D/C Mark": "C",
          "Date": "250714",
          "Currency": "USD",
          "Amount": "53944,66"
        }
      },
      {
        "type": "61",
        "option": "",
        "fieldValue": ":2507130714CD2725,28NSALSCTRSC000004FWHL//25GFKBBPF0P\n/ISIN/US0001200901/SHS/12148,",
        "content": ":61::2507130714CD2725,28NSALSCTRSC000004FWHL//25GFKBBPF0P\n/ISIN/US0001200901/SHS/12148,",
        "ast": {
          "value": "2507130714CD2725,28NSALSCTRSC000004FWHL//25GFKBBPF0P\n/ISIN/US0001200901/SHS/12148,"
        }
      },
      {
        "type": "62",
        "option": "F",
        "fieldValue": "C250714USD56669,94",
        "content": ":62F:C250714USD56669,94",
        "ast": {
          "D/C Mark": "C",
          "Date": "250714",
          "Currency": "USD",
          "Amount": "56669,94"
        }
      },
      {
        "type": "64",
        "option": "",
        "fieldValue": "C250714USD56669,94",
        "content": ":64:C250714USD56669,94",
        "ast": {
          "D/C Mark": "C",
          "Date": "250714",
          "Currency": "USD",
          "Amount": "56669,94"
        }
      }
    ]
  },
  "block2": {
    "content": "O9500153250715SBOSUS3UFIMS13447057842507150853N",
    "block_id": 2,
    "direction": "O",
    "msg_type": "950",
    "input_time": "0153",
    "input_date": "250715",
    "bic": "SBOSUS3UFIMS",
    "session_number": "1344",
    "sequence_number": "705784",
    "output_date": "250715",
    "output_time": "0853",
    "prio": "N"
  },
  "block5": {
    "block_id": 5,
    "tags": {
      "CHK": "F0FC1309E8AB"
    },
    "content": [
      {
        "name": "CHK",
        "content": [
          "F0FC1309E8AB"
        ]
      }
    ]
  },
  "blockS": {
    "name": "S",
    "content": [
      {
        "name": "COP",
        "content": [
          "P"
        ]
      },
      {
        "name": "MDG",
        "content": [
          "B7D497E702BC8EE8EDBFBCBDACF30DB07A7352E76BE40274B87FC17253462868"
        ]
      }
    ]
  }
}
java parsing swift-mt mt940