@ohmyfin/swift-draft
A zero-dependency TypeScript library for drafting, validating and translating SWIFT MT (MT103/202/202COV/199) and ISO 20022 MX (pacs.008/009/002, camt.053/054) messages. Works in Node 20+ and modern browsers without polyfills. This page itself is running the library entirely client-side — no network calls.
Install
npm install @ohmyfin/swift-draft
Or drop the UMD bundle into a static page:
<script src="https://unpkg.com/@ohmyfin/swift-draft@latest/dist/swift-draft.umd.min.js"></script>
<script>
const report = SwiftDraft.validate("MT103", { /* payload */ });
</script>
30-second example
import { serializeMt, validate } from "@ohmyfin/swift-draft";
const payload = {
senderBic: "DEUTDEFFXXX",
receiverBic: "NWBKGB2LXXX",
uetr: "eb6305c9-1f7f-4def-aaee-805b6e8b3b1a",
fields: {
"20": "TXN-2026-0001",
"23B": "CRED",
"32A": { valueDate: "260525", currency: "EUR", amount: "1234,56" },
"50K": "/DE89370400440532013000\nACME GMBH\nBERLIN",
"59": "/GB82WEST12345698765432\nBETA LTD\nLONDON",
"70": "INVOICE 2026-0001",
"71A": "SHA",
},
};
if (!validate("MT103", payload).ok) throw new Error("invalid");
const fin = serializeMt("MT103", payload);
Live demo (runs in your browser, no server)
Issues:
What it supports
- MT — MT103, MT103 STP, MT202, MT202COV, MT199 (full 5-block FIN serialisation; round-trip parser).
- MX (ISO 20022) — pacs.008.001.08, pacs.009.001.08 (core + COV), pacs.002.001.10, camt.053.001.08, camt.054.001.08 (XML with optional
BizMsgEnvlpAppHdr). - Primitives — BIC (ISO 9362), IBAN (ISO 13616 mod-97), currency (ISO 4217), country (ISO 3166-1), SWIFT date YYMMDD, ISO 8601, UETR (RFC 4122 v4), MT/MX amount formats, MT 71A charge codes, ISO 20022 charge bearers.
- Cross-field rules — CBPR+ STP intermediary ban, 33B currency / amount consistency, COV underlying-sequence presence, etc.