What is EDIFACT? Structure and how to read it

The layered structure of EDIFACT files, the delimiter characters and how to read a single line.

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:

receiver. There is one per file.

several messages; each message is one document (an order, an invoice).

quantity, MOA for an amount.

Delimiter characters

Four characters carry the structure:

CharacterRole
'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:

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.