Compiled to native code with zero-copy UTF-8 buffers and streaming split/merge for high-throughput EDI processing.
A single self-contained shared library per platform. No .NET runtime, JVM, or install step needed on the target machine.
Translate between EDI data and structured JSON: a whole X12 interchange to JSON in one call with parse, and back again with build.
Process one transaction set or segment at a time with flat, low memory use - ideal for very large interchange files.
Validate transaction sets with configurable SNIP levels, regex, date/time formats, and error limits, for a detailed report.
Automatically generate 999, 997, and TA1 acknowledgments from validated interchanges in a single operation mode.
import ctypes, json lib = ctypes.CDLL("./edifabric-x12-tools.so") lib.parse.restype = ctypes.c_int def parse(edi: bytes, mode: int = 1) -> str: cap = len(edi) * 12 out_len = ctypes.c_int(0); out_off = ctypes.c_int(0) while True: out = ctypes.create_string_buffer(cap) rc = lib.parse(edi, len(edi), mode, None, 0, out, cap, ctypes.byref(out_len), ctypes.byref(out_off)) if rc == 1: cap = out_len.value; continue if rc != 0: raise RuntimeError(f"parse failed: {rc}") return out.raw[:out_len.value].decode("utf-8")
// P/Invoke into the native library [DllImport("edifabric-x12-tools", EntryPoint = "parse")] static extern unsafe int Parse(byte* input, int inputLen, int mode, byte* config, int configLen, byte* output, int outputCap, int* outputLen, int* outputOffset); static unsafe string Parse(byte[] edi, int mode = 1) { int cap = edi.Length * 12, len, off; while (true) { var outBuf = new byte[cap]; fixed (byte* pIn = edi, pOut = outBuf) { int rc = Parse(pIn, edi.Length, mode, null, 0, pOut, cap, &len, &off); if (rc == 1) { cap = len; continue; } // grow & retry if (rc != 0) throw new Exception($"parse failed: {rc}"); return Encoding.UTF8.GetString(outBuf, 0, len); } } }
// JNA maps the native entry points to ordinary Java methods interface EdiFabricLib extends Library { EdiFabricLib INSTANCE = Native.load("edifabric-x12-tools", EdiFabricLib.class); int parse(byte[] in, int inLen, int mode, byte[] cfg, int cfgLen, byte[] out, int cap, IntByReference outLen, IntByReference outOff); } static String parse(byte[] edi) { int cap = edi.length * 12; while (true) { byte[] out = new byte[cap]; IntByReference len = new IntByReference(); int rc = EdiFabricLib.INSTANCE.parse(edi, edi.length, 1, null, 0, out, cap, len, new IntByReference()); if (rc == 1) { cap = len.getValue(); continue; } if (rc != 0) throw new RuntimeException("parse failed: " + rc); return new String(out, 0, len.getValue(), StandardCharsets.UTF_8); } }
/* Declare the entry points exported by the native library */ extern int set_map(const unsigned char* map, int len); extern int parse(const unsigned char* in, int inLen, int mode, const unsigned char* cfg, int cfgLen, unsigned char* out, int cap, int* outLen, int* outOff); extern void* get_error(int code); /* EDI -> JSON, growing the buffer once if it is too small */ int edi_to_json(const unsigned char* edi, int ediLen, unsigned char** out, int* outLen) { int cap = ediLen * 12, off = 0; *out = malloc(cap); int rc = parse(edi, ediLen, 1, NULL, 0, *out, cap, outLen, &off); if (rc == 1) { /* InsufficientCapacity */ *out = realloc(*out, *outLen); rc = parse(edi, ediLen, 1, NULL, 0, *out, *outLen, outLen, &off); } return rc; /* 0 = success */ }
P/Invoke bindings, for when you want the native library rather than ediFabric .NET.
View on GitHubThe reference header and examples that define the ABI every other binding wraps.
View on GitHubWorking in Rust, Go, Node.js or something else? They all call the same handful of C entry points, so the C bindings document contains everything you need. Tell us which language you are on and we will help you wire it up.
Community costs nothing and never expires, giving you 250 operations a day and one leased seat for non-production work. Developer and Enterprise lift the quota and the seat count, and all three include the same library.
Native is the newest of the three and covers X12 and HIPAA, with the remaining standards being released one at a time. If you need EDIFACT, HL7, NCPDP or flat files right now, use ediFabric .NET or ediFabric Cloud — your plan already includes them.
Every operation runs inside your own process, on your own hardware. No EDI data and no PHI is ever transported to us, so Native sits entirely within the controls you already have in place for HIPAA or SOC 2.