Understanding EDI X12 Delimiters and File Structure

Master the fundamentals of X12 EDI file structure: segment terminators, element separators, and the ISA/GS/ST envelope hierarchy.

Last updated: January 2025 • 8 min read

EDI X12 files look like gibberish to humans, but they're highly structured documents with specific delimiters that tell parsers where each piece of data begins and ends. Understanding delimiters is critical for anyone processing EDI files - whether you're debugging rejected transactions, building integrations, or simply trying to read a file.

What Are EDI Delimiters?

Delimiters are special characters that separate different parts of an EDI file. Think of them like punctuation in a sentence - they tell you where one word ends and another begins.

The Three Main X12 Delimiters:

  • ~
    Segment Terminator (tilde)Marks the end of each segment
  • *
    Data Element Separator (asterisk)Separates individual data elements within a segment
  • :
    Subelement Separator (colon)Separates components within a composite data element

Important: While these are the most common delimiters, the X12 standard doesn't mandate specific characters. Your trading partner could theoretically use different delimiters - but they must define them in the ISA segment.

The ISA Segment: The Rosetta Stone of EDI

The ISA (Interchange Control Header) segment is the most important segment in any X12 file. Why? Because it defines the delimiters used for the entire file.

ISA*00* *00* *ZZ*SENDERID *ZZ*RECEIVERID *250120*1430*U*00401*000000001*0*P*:~

Notice how the ISA segment is fixed length: 106 characters. This is unique to ISA - all other X12 segments are variable length.

Key ISA Elements:

  • ISA04: Element separator (the character after "ISA" - usually *)
  • ISA11: Interchange standards identifier (U = X12)
  • ISA12: Version number (00401 = version 4010)
  • ISA16: Component element separator (usually :)
  • Segment terminator: The last character of ISA (usually ~)

Pro Tip: To parse any EDI file, read the first 106 characters (the ISA segment). The 4th character is your element separator. The 106th character is your segment terminator. The 105th character (ISA16) is your subelement separator.

The X12 Envelope Structure

X12 files use a three-layer "envelope" structure. Each layer wraps around the next, like Russian nesting dolls:

ISA/IEA - Interchange Envelope

Outermost layer. Contains sender/receiver IDs and control info.

GS/GE - Functional Group Envelope

Groups transactions of the same type (e.g., all 850 POs together).

ST/SE - Transaction Set Envelope

Innermost layer. Contains the actual transaction (850, 856, 810, etc.).

ISA*00*...*:~
  GS*PO*SENDER*RECEIVER*20250120*1430*1*X*004010~
    ST*850*0001~
    BEG*00*SA*PO12345*...*20250120~
    PO1*1*100*EA*49.99*...*VP*WIDGET123~
    SE*15*0001~
  GE*1*1~
IEA*1*000000001~

Why three layers? This structure allows multiple transaction types to be sent in one file, enables error handling at different levels, and helps routers direct EDI data to the right systems.

The GS Segment: Functional Groups

The GS (Functional Group Header) segment groups together transaction sets of the same type. If you're sending 50 purchase orders and 20 invoices in one file, you'd have two GS/GE groups - one for the 850s, one for the 810s.

GS*PO*SENDERCODE*RECEIVERCODE*20250120*1430*1*X*004010~

Key GS Elements:

  • GS01: Functional identifier code (PO=Purchase Order, SH=Ship Notice, etc.)
  • GS02: Application sender code
  • GS03: Application receiver code
  • GS04: Date (CCYYMMDD format)
  • GS05: Time (HHMM or HHMMSS format)
  • GS06: Group control number (must match GE02)
  • GS08: Version/release (004010 = version 4010)

Common Delimiter Problems and Fixes

Problem: "Invalid segment structure" error

Cause: Your parser is using the wrong delimiters. Always read ISA first to determine delimiters.

Fix: Check ISA16 for the component separator and the character after "ISA" for the element separator.

Problem: Data contains delimiter characters

Example: A product description contains an asterisk: "Widget * Premium"

Fix: The X12 standard doesn't support escaping. If your data contains delimiter characters, you must choose different delimiters or remove the characters from your data.

Problem: Control numbers don't match

Error: "ST control number 0001 doesn't match SE control number 0002"

Fix: ST02 must equal SE02. GS06 must equal GE02. ISA13 must equal IEA02. These are integrity checks.

Problem: ISA segment length incorrect

Cause: ISA must be exactly 106 characters. Missing or extra spaces break parsing.

Fix: Check that all ISA fields are padded to their required lengths. ISA fields are space-padded, not zero-padded.

X12 Versions: 4010 vs 5010

Most retail EDI still uses version 4010 (technically 4010/VICS for retail). Healthcare moved to 5010 in 2012 for ICD-10 support, but retail stayed on 4010.

Key Differences:

  • Date format: 4010 uses CCYYMMDD (8 digits), 5010 added more date format options
  • Field lengths: 5010 extended some field lengths for more data
  • ICD-10: 5010 supports ICD-10 codes (healthcare-specific)
  • NPI implementation: 5010 clarified National Provider Identifier usage (healthcare)

For retail suppliers: You're almost certainly using 4010. Check ISA12 in your files - if it says "00401" or "00401VICS", you're on version 4010.

How PlainEDI Handles Delimiters Automatically

PlainEDI's parser automatically detects delimiters from the ISA segment, so you don't need to configure anything. Here's what happens when you upload a file:

  1. 1.
    Read ISA header: Extract the first 106 characters
  2. 2.
    Detect delimiters: Character 4 = element separator, character 105 = subelement separator, character 106 = segment terminator
  3. 3.
    Parse file: Use detected delimiters to split segments and elements
  4. 4.
    Validate structure: Check control numbers, segment counts, and required fields
  5. 5.
    Generate CSV: Extract data into clean columns you can read in Excel

Try It Yourself

Upload any X12 EDI file and see how PlainEDI automatically detects delimiters and parses the structure. We support all 7 major retail transaction types: 850, 855, 856, 810, 820, 846, and 997.

Convert EDI to CSV →

Frequently Asked Questions

Can I change the delimiters in an EDI file?

Yes, but you must coordinate with your trading partner. Both sender and receiver must agree on delimiters. Update ISA04 (element separator) and ISA16 (subelement separator), then use those characters consistently throughout the file. The segment terminator is defined by the last character of the ISA segment.

What if my data contains an asterisk or tilde?

The X12 standard doesn't support escape sequences. Your options: (1) Choose different delimiter characters in ISA that don't appear in your data, (2) Remove the problematic characters from your data, or (3) Replace them with similar characters (e.g., use "•" instead of "*").

Why is the ISA segment fixed length?

Fixed length allows parsers to quickly locate the delimiter definitions without needing to parse the segment first. Since the element separator position is always character 4, any parser can immediately identify how to read the rest of the file - even if it's using non-standard delimiters.

Do all X12 files use ~ and * as delimiters?

No. While ~ (segment terminator) and * (element separator) are extremely common - probably 99% of files use them - the X12 standard allows any characters. Always read the ISA segment to detect delimiters programmatically rather than assuming.

What happens if control numbers don't match?

The receiving system will reject your file with a 997 Functional Acknowledgment showing an error. Control numbers are integrity checks: ST02 must equal SE02 (transaction level), GS06 must equal GE02 (group level), and ISA13 must equal IEA02 (interchange level). Mismatches indicate corrupted or incorrectly generated files.

Related Guides