EDIFACT to JSON Converter

Paste an EDIFACT interchange and get JSON you can load in a script. Nothing is uploaded.

EDIFACT

Paste an EDIFACT file that starts with UNA, UNB or UNH.

JSON

Paste your EDIFACT on the leftabove and the JSON shows up here.

Or drop a file on this box, , or .

Why convert EDIFACT to JSON

Most of the time you don't want to read EDIFACT, you want to use it: load an order into a script, build a test fixture from a partner's file, or compare two invoices line by line. This EDIFACT to JSON converter does the parsing for you. Paste an interchange and the right pane shows the messages, each with its segments in order, one JSON object per segment, with keys like "NAD.party_function" or, if you prefer, plain positions like "NAD.01".

It handles the parts that home-made split-on-plus scripts get wrong. The separators come from the UNA line when there is one; release characters (?', ?+, ?:, ??) are removed instead of being split on; lines wrapped at a fixed width are joined back up; and the UNT and UNZ counts are checked, so you know the file is complete before you trust the JSON. The element names come from the UN/EDIFACT directories published by UNECE, written in our own short form. If your partner sends an EANCOM subset, the GS1 EANCOM pages describe which segments to expect.

Every value comes out as a JSON string exactly as written. A price of 1089.00 keeps both decimals, a GLN keeps all 13 digits, and a decimal comma from UNA:+,? ' is left as it is rather than guessed at. The conversion runs in your browser and the file is not sent anywhere. To browse the result as a table, paste it into our JSON parser.

How to convert an EDIFACT file to JSON

1

Paste the interchange

Paste an interchange or a single message into the left pane, upload an .edi or .txt file, or drop it onto the tool. Sample loads a fictional INVOIC: an IT distributor billing an office supplier for Lenovo and Dell laptops, with reverse-charge VAT.

2

Pick the key style

Named elements puts a short name after the segment tag, which reads well while you explore. Positions only gives NAD.01 and NAD.02.1, which is easier to address from code and stays the same whatever we call an element. Empty elements are left out unless you press Keep empty elements; the keys keep their positions either way. This segment:

NAD+BY+5412345000013::9++Northwind Office Supplies Ltd+St Mary?'s Road 14+Leeds++LS1 4DY+GB'

becomes this with Named elements:

{
  "segment": "NAD",
  "NAD.party_function": "BY",
  "NAD.party_identification": {
    "party_id": "5412345000013",
    "agency": "9"
  },
  "NAD.party_name": "Northwind Office Supplies Ltd",
  "NAD.street": "St Mary's Road 14",
  "NAD.city": "Leeds",
  "NAD.postal_code": "LS1 4DY",
  "NAD.country": "GB"
}
3

Check the status, then copy or download

The line under the input shows the directory, the message type and the number of segments, and warns by line when a count or reference doesn't match. Copy puts the JSON on your clipboard, Download saves it as edifact.json.

What people use EDIFACT to JSON for

Test fixtures from real files

Take an anonymised order from production, convert it, and assert on "BGM.document_number" and the LIN quantities in your tests instead of on a count of plus signs.

Loading orders into a script

Walk the segments array of each message, start a new line at every LIN, and collect its PIA, QTY and PRI. In Positions only mode the keys don't change when a partner moves to a newer directory.

Comparing two versions of an invoice

Convert both files and put the JSON side by side in our JSON diff. A changed price or an extra LIN shows up as a clear difference instead of a shifted line of text.

Explaining a file to someone new to EDI

Named keys turn QTY+21:25:PCE into a qualifier, a quantity and a unit. For someone joining an integration team, that is a quicker start than reading about electronic data interchange in the abstract.

Frequently Asked Questions

What does the JSON look like?

An object with service_string_advice (when the file has a UNA line), interchange_header (UNB), a messages array and interchange_trailer (UNZ). Each message has its type, directory (for example D96A), reference and a segments array that runs from UNH to UNT in file order. UNG and UNE go in group_segments.

How are composite elements and repetitions written?

An element with one value is a string. A composite with several components becomes an object: in Named elements mode the keys are the component names (party_id, agency), in Positions only mode NAD.02.1, NAD.02.3. An element that repeats (syntax version 4 allows that) becomes an array.

Why are numbers and dates kept as strings?

Because the exact text matters. 1089.00 as a number loses its zeros, a 14-digit GTIN can be read differently by different tools, and a decimal comma would be misread. Dates stay as written too (20261212 with its format code 102 in the next component), so nothing is guessed. Release characters are removed, so St Mary?'s Road comes out as St Mary's Road.

Which UNA settings and syntax versions does it handle?

Any UNA line: other separators, a comma as decimal mark, a different release character, or none. Without UNA the standard :+.? ' are used, plus * for repetitions when UNB says syntax version 4, and the control characters of syntax level B when the file uses them. The EDIFACT overview on Wikipedia explains where these come from.

Is the file uploaded anywhere?

No. The parser runs in your browser and the page doesn't send your file to a server.

Can I see the file as a table instead?

Use the EDIFACT viewer. It shows one row per data element with names, notes for common codes and the count checks, and its Copy as JSON button gives the same JSON as this page. For American X12 files there is an X12 viewer.

Related tools

Read the file element by element, or work with the JSON you got.