# HL7 v2 Message Parser

Parse an HL7 v2.x message into named segments, fields, components and subcomponents in your browser. MSH, PID, OBX and more, as JSON or CSV. No upload, free.

## Run it

- **CLI:** `gizza tool hl7-v2-parse 'MSH|^~\&|SENDINGAPP|SENDINGFAC|RECVAPP|RECVFAC|20240101120000||ADT^A01|MSG00001|P|2.5
EVN|A01|20240101120000
PID|1||123456^^^HOSPITAL^MR||DOE^JOHN^Q||19800101|M|||123 MAIN ST^^ANYTOWN^CA^90210
PV1|1|I|ICU^101^1'`
- **Web:** https://gizza.ai/tools/hl7-v2-parse/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/hl7-v2-parse/tool.json

## Inputs

- `data` — HL7 v2 message _(field)_
- `output` — Output format _(field)_
- `include_descriptions` — Include segment/field names (MSH, PID, OBX, …) _(field)_
- `unescape` — Decode HL7 escape sequences (\F\ \S\ \T\ \R\ \X\ \.br\) _(field)_

## Output

- Parsed message (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — HL7 v2 message
- `output` — Output format
- `include_descriptions` — Include segment/field names (MSH, PID, OBX, …)
- `unescape` — Decode HL7 escape sequences (\F\ \S\ \T\ \R\ \X\ \.br\)

Example: `https://gizza.ai/tools/hl7-v2-parse/?data=MSH%7C%5E~%5C%26%7CSENDINGAPP%7CSENDINGFAC%7CRECVAPP%7CRECVFAC%7C20240101120000%7C%7CADT%5EA01%7CMSG00001%7CP%7C2.5%0AEVN%7CA01%7C20240101120000%0APID%7C1%7C%7C123456%5E%5E%5EHOSPITAL%5EMR%7C%7CDOE%5EJOHN%5EQ%7C%7C19800101%7CM%7C%7C%7C123%20MAIN%20ST%5E%5EANYTOWN%5ECA%5E90210%0APV1%7C1%7CI%7CICU%5E101%5E1&output=json&include_descriptions=true&unescape=true`

---

## About this tool

Paste an HL7 v2.x message and get a structured breakdown of its segments, fields,
components, subcomponents, and repetitions. The parser reads the field separator and
encoding characters from the `MSH` segment, handles the special `MSH-1` / `MSH-2`
offset, and can attach human-readable names for common segments and fields such as
`MSH`, `PID`, `PV1`, `OBR`, and `OBX`.

Use **JSON** when you want the full hierarchy, including repetitions and nested
components. Use **CSV** when you want a flat table of non-empty leaf values with
locations like `PID.5.1` or `OBX.5`. The tool runs locally in your browser, so the
message text is not uploaded.

### Worked example

Input:

```text
MSH|^~\&|SENDINGAPP|SENDINGFAC|RECVAPP|RECVFAC|20240101120000||ADT^A01|MSG00001|P|2.5
EVN|A01|20240101120000
PID|1||123456^^^HOSPITAL^MR||DOE^JOHN^Q||19800101|M
```

With output `json`, descriptions enabled, and HL7 unescaping enabled, the output is a
JSON array whose first object is the `MSH` segment. `MSH.9` is split into components
`ADT` and `A01`, and `PID.5` is labeled **Patient Name** with components `DOE`,
`JOHN`, and `Q`.

With output `csv`, the same message becomes rows like:

```csv
Segment,Location,Value,Description
MSH,MSH.9.1,ADT,Message Type
MSH,MSH.9.2,A01,Message Type
PID,PID.5.1,DOE,Patient Name
PID,PID.5.2,JOHN,Patient Name
```

### Limits and edge cases

- This is a parser/viewer, not a validator against a complete HL7 conformance
  profile.
- Field descriptions are curated for common segments. Unknown fields still parse,
  but may not have a description label.
- Segment separators may be carriage returns, line feeds, or CRLF.
- HL7 escape decoding covers `\F\`, `\S\`, `\T\`, `\R\`, `\E\`, `\Xhh\`, and
  `\.br\`; turn **Decode HL7 escape sequences** off to preserve raw values.
- Output is text (JSON or CSV). The tool does not convert HL7 to FHIR or edit and
  re-serialize messages.

<details>
<summary>Does this upload protected health information?</summary>

No. The parser runs as WebAssembly in your browser tab. It has no network step and
it does not send the pasted message to a server. You should still avoid pasting real
patient data into shared machines or screen recordings.

</details>

<details>
<summary>Why is MSH field numbering different from other segments?</summary>

HL7 v2 defines `MSH-1` as the field separator itself and `MSH-2` as the encoding
characters. That means the text after `MSH|^~\&|...` starts at `MSH-3`. This tool
models that offset explicitly, so locations match HL7 field numbering.

</details>

<details>
<summary>What is the difference between JSON and CSV output?</summary>

JSON preserves the whole tree: segment → field → repetition → component →
subcomponent. CSV flattens only non-empty leaf values into rows with a `Location`
column, which is easier to paste into a spreadsheet or filter for a quick audit.

</details>

<details>
<summary>Can it validate every HL7 version and field name?</summary>

No. HL7 v2 dictionaries are large and version/profile-specific. This tool includes
common segment and field names for readability, but it does not enforce a full
conformance profile or guarantee that every field code is legal for a given version.

</details>

## Related tools

- [Extract Action Items from Meeting Notes](https://gizza.ai/tools/action-item-extractor/): Extract action items, owners, and decisions from meeting notes or daily notes with deterministic rules. Markdown checklist or JSON, private in-browser.
- [Amazon Order Analyzer](https://gizza.ai/tools/amazon-order-analyzer/): Paste an Amazon order-history CSV export to summarize total spend by month, top items, and category breakdowns. Browser-only, private, with Markdown or JSON output.
- [Base Decoder](https://gizza.ai/tools/base-decoder/): Auto-detect and decode Base16, Base32, Base45, Base58, Base64, and Base85 text, including nested layers, locally in your browser.
- [Before / after image slider generator](https://gizza.ai/tools/before-after-slider/): Turn two images into an interactive before/after comparison slider: one self-contained HTML file with inline CSS + JS, no libraries.
- [Budget Planner](https://gizza.ai/tools/budget-planner/): Plan a monthly budget from take-home pay: 50/30/20 needs/wants/savings targets with custom splits, or a zero-based plan showing what's left to allocate.
