EDI X12 Parser

Parse EDI X12 documents

1
Understanding EDI X12 Messages
TL;DR

EDI X12 is the North American standard for electronic business document exchange — purchase orders, invoices, and payment remittances.

What is EDI X12?

EDI X12 (Electronic Data Interchange, ANSI ASC X12) is the predominant standard for electronic business document exchange in North America. Developed by the Accredited Standards Committee X12 (originally chartered by ANSI in 1979), it defines standardized formats for common business documents such as purchase orders (850), invoices (810), payment remittances (820), advance ship notices (856), and hundreds more.

EDI replaces paper-based business processes with structured electronic messages that can be processed automatically by computer systems. Instead of mailing a paper purchase order that must be manually keyed into the supplier’s system, a buyer’s ERP system generates an EDI 850 that the supplier’s system can ingest directly — eliminating data entry errors, reducing processing time from days to minutes, and cutting costs significantly.

Despite the rise of APIs and XML-based alternatives, EDI X12 remains deeply entrenched in supply chain, healthcare, transportation, and financial services. Major retailers (Walmart, Amazon, Target), healthcare payers, and logistics companies require their trading partners to communicate via EDI.

Message Structure

Every EDI X12 interchange uses a three-layer envelope structure — like nested boxes — that provides routing, grouping, and transaction-level organization.

EDI X12 Envelope Structure A nested box diagram showing three concentric layers of the EDI X12 envelope: the outer ISA/IEA Interchange Control layer, the middle GS/GE Functional Group layer, and the inner ST/SE Transaction Set layer containing the business data segments. ISA Interchange Control Header Sender/Receiver IDs, date, control number, delimiters GS Functional Group Header Functional ID (IN=Invoice, PO=Purchase Order), version ST Transaction Set Header Transaction set ID (810, 850, 820...), control number BIG*20240315*INV-2024-001*20240310*PO-2024-500~ N1*ST*ACME CORPORATION*92*SHIP001~ IT1*1*100*EA*25.00**VP*WIDGET-A~ TDS*462500~ Business data segments (varies by transaction set type) SE Transaction Set Trailer — segment count + control number GE Functional Group Trailer — transaction set count + group control number IEA Interchange Control Trailer — functional group count + interchange control number

ISA/IEA (Interchange Control) is the outermost envelope. It identifies the sender and receiver, sets the delimiters, and wraps one or more functional groups. The ISA segment is always exactly 106 characters.

GS/GE (Functional Group) groups related transaction sets. A single interchange can contain multiple functional groups (e.g., one group of invoices and one group of purchase orders). The GS identifies the functional type (IN = Invoice, PO = Purchase Order).

ST/SE (Transaction Set) contains the actual business document. The ST segment identifies the transaction set type (810 for invoice, 850 for purchase order) and assigns a control number. The SE segment counts the segments and closes the transaction.

Common Transaction Sets

SetNameDirectionDescription
810InvoiceSeller to BuyerBilling for goods or services delivered
850Purchase OrderBuyer to SellerRequest to buy specific items at agreed prices
820Payment Order/Remittance AdvicePayer to PayeePayment instructions with invoice references
856Advance Ship Notice (ASN)Seller to BuyerNotification of shipment with packing details
997Functional AcknowledgmentReceiver to SenderConfirms receipt and syntactic correctness
834Benefit EnrollmentEmployer to PayerHealthcare enrollment and changes
835Healthcare Claim PaymentPayer to ProviderExplanation of benefits and payment details
837Healthcare ClaimProvider to PayerMedical claim submission

EDI vs Modern Alternatives

FeatureEDI X12XML/JSON API
FormatFixed positional + delimitedHierarchical markup/object
Human-readableDifficultEasy
Schema validationImplementation guidesXSD / JSON Schema
TransportVAN, AS2, SFTPHTTPS REST/SOAP
AdoptionUniversal in supply chainGrowing, not universal
Real-timeTypically batchReal-time capable
CostVAN fees per KBAPI hosting costs

Common Use Cases

  • Supply chain management: Purchase orders (850), invoices (810), and ASNs (856) automate the procure-to-pay cycle between retailers and suppliers
  • Healthcare claims: 837 (claim submission), 835 (remittance), and 834 (enrollment) are mandated by HIPAA for US healthcare transactions
  • Payment processing: 820 (payment order) and 823 (lockbox) automate B2B payment instructions and cash application
  • Transportation: 204 (load tender), 214 (shipment status), and 210 (freight invoice) coordinate logistics between shippers and carriers
  • Retail compliance: Major retailers require EDI for all vendor transactions — non-compliance results in chargebacks and penalties
  • Financial reporting: 822 (customer account analysis) and 821 (financial information reporting) support treasury operations

Try These Examples

Valid 810 Invoice Valid

A valid EDI X12 810 (Invoice) wrapped in the standard three-layer envelope: ISA/IEA (interchange), GS/GE (functional group), ST/SE (transaction set). The invoice references PO-2024-500, ships to ACME CORPORATION, contains two line items (100 widgets at $25.00, 50 gadgets at $42.50), and totals $4,625.00 (TDS segment in cents).

ISA*00* *00* *ZZ*SENDERID *ZZ*RECEIVERID *240315*1200*U*00401*000000001*0*P*>~ GS*IN*SENDERID*RECEIVERID*20240315*1200*1*X*004010~ ST*810*0001~ BIG*20240315*INV-2024-001*20240310*PO-2024-500~ N1*ST*ACME CORPORATION*92*SHIP001~ IT1*1*100*EA*25.00**VP*WIDGET-A~ IT1*2*50*EA*42.50**VP*GADGET-B~ TDS*462500~ SE*8*0001~ GE*1*1~ IEA*1*000000001~
Invalid EDI (Missing GE Trailer) Invalid

This EDI interchange is missing the GE (Functional Group Trailer) segment between the SE and IEA segments. The GE segment is mandatory and must contain the number of transaction sets in the group and the group control number matching the GS header. Without it, the receiving system cannot validate group integrity.

ISA*00* *00* *ZZ*SENDERID *ZZ*RECEIVERID *240315*1200*U*00401*000000002*0*P*>~ GS*IN*SENDERID*RECEIVERID*20240315*1200*2*X*004010~ ST*810*0001~ BIG*20240315*INV-2024-002~ TDS*100000~ SE*4*0001~ IEA*1*000000002~