HL7 v2 encoding characters (delimiters)
HL7 v2 messages are delimited text. The field separator is declared as MSH-1 (conventionally |), and MSH-2 declares the four encoding characters in order: component separator ^, repetition separator ~, escape character \, and subcomponent separator &. Every parser reads these five characters from the MSH segment itself, so a message carries its own delimiter declaration.
| Field separator | | declared by MSH-1 (the 4th character of the message) |
|---|---|
| Component separator | ^ (1st character of MSH-2) |
| Repetition separator | ~ (2nd character of MSH-2) |
| Escape character | \ (3rd character of MSH-2) |
| Subcomponent separator | & (4th character of MSH-2) |
| MSH-2 datatype | ST, required, max length 4 |
Example
MSH|^~\&|PIDGEON^^L|PIDGEON_FACILITY|TARGET^^L|TARGET_FACILITY|20260722160847||ADT^A01^ADT_A01|984078|P|2.3||||||8859/8|zh^Chinese^ISO639^^^Engine-generated with `pidgeon generate ADT^A01 --seed 42` (timestamps vary per run). Read the first nine characters: MSH, then | as MSH-1, then ^~\& as MSH-2. MSH-9 shows the component separator in use: ADT^A01^ADT_A01 is three components of one field.
Validation context
Strict and compatibility validation notes land here with the phase-1 data export.
This answer, in your terminal
pidgeon lookup MSH.2Wire it into your AI agent:
claude mcp add pidgeon -- npx -y @pidgeonhealth/mcpDownload Post free to browse this reference with generation attached.