---
title: Line Break EDIFACT/X12 EDI Messages in Nodinite Log Views
description: Transform single-line EDIFACT or X12 EDI messages into readable, segment-per-line output in Nodinite Log Views using Liquid stylesheets for faster troubleshooting and validation.
---

:new6.1.0.112:  
:new7.x:

# Line break an EDIFACT/X12 message in Nodinite Log View

**Transform dense, single-line EDI messages into readable output with :Nodinite: Liquid [Stylesheets][].** Operators and integrators gain instant visibility into EDIFACT and X12 message structure in [Log Views][], eliminating the need to copy messages into external tools for inspection. On this page, you will learn how to create a Liquid stylesheet that presents EDI segments line-by-line directly in Log Views for faster troubleshooting and validation.

Benefits:

* ✅ Faster troubleshooting — present segment-per-line output for quick scanning  
* ✅ Reduced cognitive load — show business-level segments instead of a single dense line  
* ✅ Easier validation — terminators remain visible to speed protocol checks  

![Line break an EDIFACT INVOIC with a Liquid Stylesheet in a Log View, animated walkthrough (7.12)][1]  
*Animated walkthrough: the INVOIC first as one line with **View message body**, then with **View message formatted as** the Stylesheet, one segment per line with the apostrophe kept.*  

This page shows a minimal, working Liquid stylesheet that turns a single-line EDIFACT or X12 message into a readable, line-broken view in a :Nodinite: [Log View][Log Views]. See the [Stylesheets Overview][] for management and deployment details.

```mermaid
flowchart LR
    EDIFACT["fa:fa-file-lines EDIFACT Message"] --> Stylesheet["fa:fa-droplet Liquid Stylesheet<br/>in Log View"]
    X12["fa:fa-file-lines X12 Message"] --> Stylesheet
    Stylesheet --> Output["fa:fa-align-left User-friendly output<br/>with line breaks"]
    style EDIFACT fill:#2678BD,color:#fff
    style X12 fill:#2678BD,color:#fff
    style Stylesheet fill:#E47528,color:#fff
    style Output fill:#93d16d,color:#000
```

*Single-line EDI messages (blue) pass the Liquid Stylesheet (orange) and appear one segment per line (green).*

## Message Body Processing Options

>[!IMPORTANT]
>⚠️ This setting controls whether you use Liquid variables or JavaScript parsing.

On the Stylesheet management page (see [Add or manage Stylesheet][]), the **Message Body is Json** checkbox determines how data is accessed:

### When CHECKED: "Message Body is Json"

* Nodinite parses JSON and injects properties as **direct Liquid variables**
* Access via: `{{ orderId }}`, `{{ customer.name }}`, `{{ items | size }}`  
* Use Liquid syntax: `{%- for item in items -%}`
* **Simple, performant, recommended for JSON data**
* Example: [1-Order-Received][] in the O2C demo

### When UNCHECKED: "Message Body is NOT Json"

* Message body is treated as **raw string** accessible via `{{data}}`
* Manipulate with string transformations: `.replace(/'/g,"'\n")`
* Requires JavaScript parsing for complex data: `JSON.parse(dataStr)`
* This is the EDIFACT stylesheet approach shown below

>[!IMPORTANT]
>:Nodinite: parses the body as JSON only when **Message Body is Json** is checked **and** the body is JSON. EDIFACT and X12 aren't JSON, so the raw EDI message always reaches the template as `{{data}}`, whether the checkbox is checked or not.

---

## EDIFACT Message Examples

* Segment terminator is an apostrophe `'` character.

```edifact
UNB+UNOB:1+SENDER1:1+RECEIVER1:1+071101:1701+131++INVOIC++1++1' UNG+INVOIC+2:1+3:4+971013:1040+5+UN+D:96A:UN+PASSPORT' UNH+509010117+INVOIC:D:96A:UN' BGM+380+IN432097' DTM+137:20020308:102' PAI+::42' RFF+ON:ORD9523' DTM+171:20020212:102' RFF+PL:PL99523' DTM+171:20020101:102' RFF+DQ:53662' DTM+171:20020215:102' NAD+BY+5412345000013::9' RFF+VA:4146023' NAD+SU+4012345500004::9' RFF+VA:VR12345' NAD+DP+5412345678908::9' CUX+2:EUR:4' PAT+1++5:3:M:2' PAT+22++5:3:D:10' PCD+12:2.5:13' ALC+C++6++FC' MOA+23:120' TAX+7+VAT+++:::19+S' MOA+124:22.80' LIN+1++4000862141404:SRS' QTY+47:40' MOA+203:2160' PRI+AAB:60:CA' TAX+7+VAT+++:::21+S' MOA+124:453.60' ALC+A' PCD+1:10' LIN+2++5412345111115:SRS' QTY+46:5' QTY+47:12.65:KGM' MOA+203:2530' PRI+AAA:200:CA::1:KGM' TAX+7+VAT+++:::19+S' MOA+124:480.70' UNS+S' CNT+2:2' MOA+86:5767.10' MOA+79:4690' MOA+129:5767.10' MOA+125:4810' MOA+176:957.10' MOA+131:120' TAX+7+VAT+++:::19+S' MOA+124:503.50' TAX+7+VAT+++:::21+S' MOA+124:453.60' ALC+C++++FC' MOA+131:120' UNT+53+509010117' UNE+1+5' UNZ+2+131'
```

## X12

* Segment terminator is a tilde `~` character.

```x12
ISA*00*00*00*00*ZZ*SENDERID*ZZ*RECEIVERID*210101*1200*U*00401*000000001*0*P*>~GS*IN*SENDERID*RECEIVERID*20210101*1200*1*X*004010~ST*810*0001~
```

## How it works

The [Stylesheet][Stylesheets] is **Liquid** on the raw body (`{{data}}`), not XSLT. Its JavaScript replaces the common segment terminators with a visible line break while keeping the terminator intact. CodeMirror and jQuery come with the page that renders a Stylesheet, so the template doesn't load them.

>[!WARNING]
>**Script Execution Requirement:** This stylesheet contains embedded JavaScript code. The [StylesheetScriptsEnabled][] system parameter **must be set to `true`** for this stylesheet to execute. With `false`, :Nodinite: silently removes every `<script>` block from a Liquid template before rendering: you see only the empty text area, and no error. The default is `false` on a new installation; an upgraded installation keeps its value (it was seeded `true` before 7.12). Only members of the built-in **Administrators** role can change this parameter. See [StylesheetScriptsEnabled][] for security considerations.

```liquid
<textarea rows="50" cols="50" style="border: none;outline: none;" id="demo"> </textarea>
    <pre id="demoprint" style="margin:0; padding:0; border:none; display:none;"></pre>
    <script>
        var editor;
        function codemirroreditor(elem) {
            var mime = 'application/xml';
             editor = CodeMirror.fromTextArea(elem, {
                lineNumbers: true,
                mode: mime,
                indentWithTabs: true,
                smartIndent: true,
                lineNumbers: true,
                matchBrackets: true,
                lineWrapping: true,
                autofocus: true,
                autoRefresh: true,
                extraKeys: { "Ctrl-Space": "autocomplete" }
            });
        }
        var content = `{{data}}`.replace(/'/g,"'\n");
      
        function displayXml() {
            var elem = document.getElementById('demo');
            elem.value = content;
            codemirroreditor(elem);
        };

        function htmlEntities(str) {
            var htmlString = String(str).replace(/&/g, '&amp;').replace(/</g,'&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
            return htmlString;
        }
        
        window.addEventListener('beforeprint', (event) => {
            $(editor.getWrapperElement()).hide();
            $("#demoprint").html(htmlEntities(content)).show();
        });
        
        window.addEventListener('afterprint', (event) => {
            $(editor.getWrapperElement()).show();
            $("#demoprint").hide();
        });

        displayXml();
        </script>

<style>
  html {height:calc(100vh - 200px); min-height:500px;}
  body {height:100%;}
  .CodeMirror {
    min-height: 200px;
    height: 100%;
  }
</style>
```

*Example of a liquid [Stylesheet][Stylesheets] to line break EDIFACT/X12 messages in a :Nodinite: [Log View][Log Views].*  

### Notes

* The EDI message is always in `{{data}}`, whatever **Message Body is Json** says, because EDIFACT and X12 aren't JSON (see [Message Body Processing Options](#message-body-processing-options) above)
* The template stores the line-broken message in the JavaScript variable `content`—this is a client-side variable, not related to the Liquid `{{data}}` variable
* The stylesheet keeps segment terminators (`'` for EDIFACT or `~` for X12) visible. If you prefer to remove them, change `.replace(/'/g,"'\n")` to `.replace(/'/g,"\n")` for EDIFACT, or use `/~/g` for X12
* For X12 messages, change the `var content` line to: `var content = \`{{data}}\`.replace(/~/g,"~\n");`
* The CodeMirror editor provides syntax highlighting and is configured for XML mode—adjust the `mime` variable if needed for your use case
* Bind the Stylesheet to the [Message Types][] of your EDI messages so the Log View offers it

## :fa-hand-point-right: Next Steps

* :fa-square-plus: [Add or manage Stylesheet][] - Install the Liquid stylesheet into :Nodinite: and test in a dedicated [Log View][Log Views]  
* :fa-gears: [StylesheetScriptsEnabled][] - Allow the embedded JavaScript to run  

## :fa-link-horizontal: Related Topics

* :fa-search: [Log Views][] — overview and features for creating role-specific Log Views  
* :fa-file-lines: [Stylesheets][Stylesheets] — overview of stylesheet features and management  
* :fa-code: [Stylesheet Examples][] — all XSLT and Liquid examples  
* :fa-file-code: [Base64Decode XML from JSON][] — another Liquid example with JavaScript  
* :fa-tags: [Message Types][] — decide which Stylesheet formats a [Log Event][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Customize/Stylesheets/Stylesheet_EdifactLineBreak.gif

[1-Order-Received]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Stylesheets/1-Order-Received.md
[Add or manage Stylesheet]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/Add%20or%20manage%20Stylesheet.md
[Base64Decode XML from JSON]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/Base64Decode%20XML%20from%20JSON.md
[Log Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Stylesheet Examples]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/Overview.md
[Stylesheets]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/What%20is%20a%20Stylesheet.md
[Stylesheets Overview]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Overview.md
[StylesheetScriptsEnabled]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/StylesheetScriptsEnabled.md