A blazing-fast, stream-based command-line tool written in Rust to convert legacy version 1 (JPK_VAT(3) schema 1-1) and version 2 (JPK_V7M(2) / JPK_V7K(2)) XML files to the mandatory output JPK_V7(3) format required by the Polish Ministry of Finance (KAS) from February 2026. It also supports native JPK_V7(3) processing for pretty-printing, variant switching, and generating conversion summaries.
- Schema Upgrade: Automatically updates XML namespaces,
kodSystemowy, and root attributes. - M/K Variant Control: Automatically detects if the source is Monthly (M) or Quarterly (K) and allows explicit overrides via CLI flags.
- Automated Control Totals: Recalculates
PodatekNaleznyandPodatekNaliczonybased on mandatory V3 summation rules, warns about discrepancies inSprzedazCtrl/ZakupCtrl, and saves the warning as a comment in the output file next to the problematic element. - Summary: Optional detailed green summary at the end of conversion (enabled with
-s). - Row Management: Automatically updates
LiczbaWierszySprzedazyandLiczbaWierszyZakupowcounters. - Strict Compliance: Injects mandated choice tags (
<BFK>1</BFK>or<DI>1</DI>) and ensures strict element sequence inNaglowek. - Podmiot1 Modernization: Nests legacy flat structures into compliant
OsobaNiefizyczna/OsobaFizycznablocks and ensures mandatoryEmailpresence. - Memory Efficient: Processes large JPK structures directly as an event stream (
quick-xml), handling files natively without loading the entire DOM into RAM.
Ensure you have Rust and Cargo installed, then build the binary:
git clone https://github.com/jza70/jpk23.git
cd jpk23
cargo build --releaseThe executable for your current platform will be generated at target/release/jpk23.
This project includes a GitHub Actions workflow to automatically build and release binaries for Windows, Linux, and macOS (x86_64 and ARM64).
To trigger a build:
- Push a version tag:
git tag v1.0.1 && git push origin v1.0.1 - The binaries will be automatically built and attached to a new GitHub Release.
To build Linux binaries from Windows/macOS, it is recommended to use cross:
cargo install cross
cross build --release --target x86_64-unknown-linux-gnujpk23 --in res/v2_sample.xml --out output_v3.xml -u 1438 -s-i, --in [FILE]: Specify the input JPK_V7 XML file. Supports Version 1, 2, and 3. Reads fromstdinif omitted.-o, --out [FILE]: Specify the output JPK_V7(3) XML file. Writes tostdoutif omitted.-u, --urzad [CODE]: Set theKodUrzedu(Tax Office Code) in the header (mandatory in V3).-m, --v7m: Force output variant to JPK_V7M (Monthly).-k, --v7k: Force output variant to JPK_V7K (Quarterly).-n, --namespace [PREFIX]: Set a custom namespace prefix (e.g.jpk). Use without value to strip prefixes entirely.-p, --pretty: Format the output XML with indentation (pretty print).-q, --quiet: Suppress XML output (useful for pure validation or summary).-s, --summary: Print summary at the end of the conversion (in green tostderr).-h, --help: Display help information.-v, --version: Print version and license info.
jpk23 supports joining single-letter options (flags) into a single block. If an option requires a value (like -i, -o, or -u), it must be the last letter in the cluster.
jpk23 -qsi input.xml(This is equivalent to jpk23 -q -s -i input.xml)
jpk23 -i source.xml -o converted.xml -u 1438 -sjpk23 -i source.xml -q -sjpk23 -i source.xml -o converted.xml -k -pjpk23 -i source.xml -o converted.xml -nThe tool automatically recalculates control sums during processing. If the values in the source file differ from the calculated sums, a warning is displayed and the comment is added to the output file.
With --summary or -s flag, the tool prints a summary of the conversion at the end. It shows the original version of the file, the taxpayer's NIP, the number of sales and purchase records, the total sales and purchase base and VAT, the maximum and minimum sales and purchase VAT, and the breakdown of sales and purchase VAT by rate.
=============================================================
CONVERSION SUMMARY
=============================================================
Original Version: V2
Taxpayer NIP: 5550000000
-------------------------------------------------------------
SALES (PLN):
Records: 2
Total Net: 1 239 567.89
Total VAT: 284 350.62
Max VAT (Row): (1) 283 950.62
Min VAT (Row): (2) 400.00
Rate Breakdown: Net VAT
23% 1 234 567.89 283 950.62
8% 5 000.00 400.00
5% 0.00 0.00
Other 0.00 0.00
-------------------------------------------------------------
PURCHASES (PLN):
Records: 1
Total Net: 200.00
Total VAT: 46.00
Max VAT (Row): (1) 46.00
Min VAT (Row): (1) 46.00
-------------------------------------------------------------
FINAL VAT BALANCE (PLN): 284 304.62
=============================================================
- Native JPK_V7(3) Support: Added ability to process already-converted V3 files as input.
- Quiet Mode: Added
-q, --quietflag to suppress XML output (useful for validation/summary). - Clustering Support: Improved CLI experience to allow joining single-letter options (e.g.
-qsi). - Robust Flags: Standardized boolean flags to be idempotent and allow multiple occurrences.
- Automation: Added GitHub Actions for automated cross-platform builds (Windows, Linux, macOS).
- Initial Release: Complete JPK_V7(1) and JPK_V7(2) to JPK_V7(3) conversion logic.
- Audit Summary: Implementation of professional green terminal summary with precise alignment.
- Symmetry: Symmetrical layout for summary statistics (61-character width).
- Namespace Control: Added support for stripping or prefixing namespaces.