What is EDIFACT? Structure and how to read it
EDIFACT (Electronic Data Interchange For Administration, Commerce and Transport) is an international standard for electronic data interchange developed by the United Nations. It is the de facto standard in European retail, logistics and automotive; North America largely uses ANSI ASC X12 instead.
Why does it look like that?
An EDIFACT file is unreadable at first glance:
UNB+UNOC:3+8712345678901:14+8798765432109:14+260117:1030+REF00042'
This is a deliberate design choice. The standard was created in the 1980s when line capacity was expensive and every character cost money. Rather than a format that repeats tags, like XML or JSON, it uses a tight structure where meaning is derived from position.
Three layers
An EDIFACT file consists of three nested layers:
- Interchange — opens with
UNB, closes withUNZ. Carries the sender and
receiver. There is one per file.
- Message — opens with
UNH, closes withUNT. One interchange may hold
several messages; each message is one document (an order, an invoice).
- Segment — every line is a segment.
NADfor an address,QTYfor a
quantity, MOA for an amount.
Delimiter characters
Four characters carry the structure:
| Character | Role |
|---|---|
' | Segment terminator |
+ | Element separator |
: | Component separator |
? | Release (escape) character |
|---|
If one of these characters appears inside a value, it is preceded by ?. For example ACME?+PARTNERS reads the + as a letter rather than a separator. Ignoring this escape rule is where parsers most often break.
The delimiters are not fixed: if the file opens with a UNA segment, they are read from there.
Reading a line
NAD+SU+8712345678901::9++ACME FOODS BV+Havenweg 5+ROTTERDAM+3011AA+NL'
Split into elements:
NAD— segment code: party and addressSU— role: supplier8712345678901::9— party identifier;9indicates the GS1 standard- (empty) — unused element
ACME FOODS BV— company nameHavenweg 5— streetROTTERDAM— city3011AA— postcodeNL— country
Note that empty elements are not omitted; they stay in place as ++. Meaning comes from position, so dropping one shifts everything after it.
Where to go next
Work through the segment reference to go segment by segment, or the message types section to understand a particular kind of document.