Home /  EDI Translate / 

Translate X12 EDI to JSON

EDI Translate takes X12 EDI and turns it into a JSON document. You need a Stedi guide that describes the structure of the document. The shape of the JSON document resembles the original X12 EDI, but you can map it into any shape you need.

  • See also: Create a Stedi guide
  • See also: Map a JSON document

Envelopes

The input EDI should always contain the transaction set envelope (ST). The interchange envelope (ISA) and functional group envelope (GS) are optional, but if you provide either, you should provide both.

At the moment, it isn’t possible to translate EDI documents with multiple functional groups. Multiple transaction sets within the same functional group works fine, though.

Calling the API

You translate a document by calling the API. First you need an API key and then you can call the EDI Translate endpoint: https://edi-translate.us.stedi.com/2022-01-01/x12/to-json.

const axios = require("axios");

const apiKey = process.env.STEDI_API_KEY;

async function x12ToJson(guideId, document) {
  const response = await axios({
    method: "post",
    url: "https://edi-translate.us.stedi.com/2022-01-01/x12/to-json",
    data: {
      guideId: guideId,
      input: document,
    },
    headers: { Authorization: `Key ${apiKey}` },
  });

  return response.data;
}
EnvelopesCalling the API