Radar

Home › Guides

Convert MT940 to CAMT.053: free online or in 10 lines of Python

2026-11-27 · also on DEV

To convert MT940 to CAMT.053 you have two options: upload the file to a free browser converter that needs no sign-up (MT940 to CAMT.053 online), or run it offline with the open-source Python package pip install mt940-camt053. MT940 is the older SWIFT text format for bank statements (tags such as :61: and :86:), and CAMT.053 is the ISO 20022 XML format that banks are moving to. Both routes read the MT940 file, check that opening balance plus transactions equals closing balance, and write CAMT.053 XML.

What is inside an MT940 file

An MT940 file is plain text. Each line starts with a tag. These are the tags the package reads (from its README and source):

Tag Meaning
:20: Statement reference
:25: Account identification
:28C: Statement / sequence number
:60F: / :60M: Opening balance (final / intermediate)
:61: One transaction: value date, booking date, debit or credit, amount, references
:86: Free text for the transaction before it (purpose, counterparty, IBAN)
:62F: / :62M: Closing balance (final / intermediate)
:64: Available balance

The package also reads several statements in one file, the {1:}{2:}{4: -} SWIFT envelopes, and CRLF or LF line endings. In :86: it understands the German structured fields (?20 to ?29 purpose, ?30 BIC, ?31 IBAN, ?32 and ?33 name) and the /EREF/../NAME/../REMI/.. and EREF+ / SVWZ+ / MREF+ keyword styles.

Convert it in Python

The package needs only lxml (and openpyxl if you also want Excel output). This is a small MT940 statement with two transactions, saved as statement.sta:

:20:DE2611
:25:50010517/5413161111
:28C:00007/001
:60F:C261101EUR2500,00
:61:2611021102D99,90NMSCKREF1234//KB77
ABC12
:86:166?00Lastschrift?10931?20EREF+E2E-1234 SVWZ+Rechnung?21 5567 vom 01.11.2026 Kunde ?2212345 Danke?30COBADEFFXXX?31DE89370400440532013000?32Mueller + Soehne GmbH?33Abt. Einkauf?34000
:61:261105C1234,56NTRFNONREF
:86:051?00Gutschrift?20SVWZ+Zahlung Auftrag A-88?32Anna Schmidt
:62F:C261105EUR3634,66
-

And the script:

import mt940_camt053 as mc

stmts = mc.load("statement.sta")
for st in stmts:
    state, diff = mc.balance_check(st)
    print("account:", st["acct"], "| balance check:", state, diff)
    for t in st["txs"]:
        print(t["bdate"], t["amt"], t["name"], t["iban"], t["remit"])

xml = mc.to_camt053(stmts)
open("statement-camt053.xml", "wb").write(xml)
print(len(xml), "bytes of camt.053.001.08")

Real output of that script:

account: 50010517/5413161111 | balance check: ok 0.00
2026-11-02 -99.90 Mueller + Soehne GmbH Abt. Einkauf DE89370400440532013000 Rechnung 5567 vom 01.11.2026 Kunde 12345 Danke
2026-11-05 1234.56 Anna Schmidt  Zahlung Auftrag A-88
3241 bytes of camt.053.001.08

The CAMT.053 file it wrote contains the opening and closing balances and one <Ntry> per transaction. The first debit looks like this (excerpt):

<Ntry>
  <Amt Ccy="EUR">99.90</Amt>
  <CdtDbtInd>DBIT</CdtDbtInd>
  <RvslInd>false</RvslInd>
  <Sts><Cd>BOOK</Cd></Sts>
  <BookgDt><Dt>2026-11-02</Dt></BookgDt>
  <ValDt><Dt>2026-11-02</Dt></ValDt>
  <AcctSvcrRef>KB77</AcctSvcrRef>
  ...
  <RmtInf><Ustrd>Rechnung 5567 vom 01.11.2026 Kunde 12345 Danke</Ustrd></RmtInf>
</Ntry>

(I shortened the whitespace and left out the party and bank-code elements; the file itself is the full indented XML.) The default output is camt.053.001.08. For older systems pass version="001.02" to to_camt053.

One line on the command line

mt940-camt053 statement.sta -o cli-out.xml

Real output:

statement.sta -> cli-out.xml: 2 transactions in 1 statement(s), balance check ok

The same command works in the other direction: give it a CAMT.053 .xml and it writes MT940. Add --to csv or --to xlsx for a flat table.

Common problems

Limits

PDF or scanned statements are not read, because that needs OCR; the package raises a plain error for a PDF. Going from CAMT.053 back to MT940 cuts long texts at 6 lines of 65 characters, and the notes argument tells you when that happened.

Package: mt940-camt053 on PyPI (MIT licence, runs locally, no network calls).

Disclosure: I build the tool used in this post, and the article was written with AI assistance. If a code sample does not work for you, tell us at radarbg.com/support and we fix it.

More guides