Skip to content

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 datatypeST, 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.2

Wire it into your AI agent:

claude mcp add pidgeon -- npx -y @pidgeonhealth/mcp

Download Post free to browse this reference with generation attached.

HL7® and FHIR® are registered trademarks of Health Level Seven International.

Published by Pattern Engine LLC (Pidgeon Health).

Rendered from the same machine-readable definitions the Pidgeon engine validates against. Hand-authored reference page (phase 1b); example generated with the Pidgeon CLI at seed 42; MSH-2 facts verified with pidgeon lookup.