HL7 v2 Parser
Decode a pipe-delimited HL7 v2.x message segment by segment, 100 % client-side. Type, version, encoding characters, field-by-field table.
Paste an HL7 v2 message (MSH segment first) to parse it.
How it works
HL7 v2 (v2.5.1 and earlier) serialises messages as segments separated by
carriage returns. Each segment opens with a 3-character identifier
(MSH, PID, EVN…) followed by
|-separated fields.
The parser runs in two phases:
- Read the MSH segment: the 4th character defines the field separator (MSH-1); the next 4 characters define the component / repetition / escape / sub-component separators (MSH-2). All 5 must be unique.
- Tokenise the remaining segments using those characters.
Every field is broken into repetitions, components and sub-components
so positional access such as
PID-5.1.1remains stable.
Encoding characters
The five HL7 v2.x encoding characters defined in chapter 2 section 2.5 must all be unique:
|— field separator (MSH-1).^— component separator.~— repetition separator.\— escape character (for\F\,\S\,\R\,\E\,\T\).&— sub-component separator.
A message that deviates from those defaults (for example
$%&\#) remains valid as long as the 5 characters stay
unique. The parser reads whatever values appear in MSH-1 and MSH-2.
Recognised message types
The parser does not enforce a type: it extracts the message type and
trigger event from MSH-9 (code^triggerEvent^messageStructure)
and the version from MSH-12. The most common types are:
- ADT — Admit / Discharge / Transfer (admissions, transfers, discharges).
- ORM / OMG / OMD / OMP — Orders (lab, imaging, pharmacy).
- ORU — Observations / results.
- SIU — Scheduling Information Unsolicited (appointments).
- BAR — Add / Change Billing Account.
- MFN — Master File Notification.
Limitations
-
The parser does not validate the content of
non-MSH segments.
PID-3, for instance, may contain anything from this tool's standpoint. -
Escape sequences (
\F\,\S\, …) are preserved verbatim — you see the escaped character exactly as sent. -
The tool does not strip the MLLP framing (preamble
\x0B/ trailer\x1C\x0D): paste only the textual payload between the MLLP boundaries. -
Segment groupings (e.g.
PID/{ NK1 }inside ADT_A01) are not reconstructed — the segment list is flat.
Privacy
Related documentation
- HL7 v2.x — the standard, its history and ecosystem.
- Official spec: HL7 v2.5.1 product brief.
- FHIR R5 — the RESTful successor to HL7 v2, in JSON / XML.