Free HL7 test files and sample generator
The pipe-delimited message format hospital systems use to exchange patient, order and result data. Generate valid HL7 v2 sample files to test integration engines, parsers and interface feeds.
What is a .hl7 file?
HL7 v2: Healthcare Message. HL7 v2 is how hospital systems talk to each other, and it has been in production since the late 1980s. A message is a list of segments separated by carriage returns, each beginning with a three-letter identifier, MSH for the header, PID for the patient, OBX for an observation. The first two fields of MSH declare the delimiters the rest of the message uses, which is why every HL7 file starts with the distinctive `MSH|^~\&`. Nothing in a generated file resembles a real patient: the names, record numbers and results are synthetic.
Why generate a test HL7 file?
- Test an integration engine, interface feed or HL7 parser.
- Exercise segment and field parsing, including custom Z-segments.
- Check how a system handles a message that arrives with no observations.
What you can put inside a .hl7 file
You get 3 content options for HL7, so the file holds something meaningful rather than random padding: Lab result (ORU), Admission (ADT), Order (ORM). For HL7 these are alternatives, so choose the one that matches what you need to test.
How a .hl7 file is identified
A .hl7 file has no signature at the start. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
Negative testing with broken HL7 files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed. Same length as the valid file.
- Incomplete. Truncated part-way, so it is genuinely shorter.
- Empty. Chosen under Content rather than File Condition: valid structure, no data.
Which failure to reach for, and what to assert for each, is covered in how to make a corrupted file for testing. For upload limits and type checks see testing file upload validation, and for this format's encodings, UTF-16 and BOM test files.
Sample HL7 content
MSH|^~\&|SENDING_APP|SENDING_FAC|RECEIVING_APP|RECEIVING_FAC|20260727091400||ADT^A01|MSG00001|P|2.5 PID|1||100001^^^HOSP^MR||Smith^James^A||19850312|M
This shows the shape of the file. Your download is generated fresh at the size you choose, so the values will differ.
How to open and verify the file
Open it in any text editor, but note the segments are separated by a bare carriage return, so editors that expect Windows or Unix line endings may show it as one long line. HL7 Inspector, 7Edit or a Mirth Connect channel will parse it properly.
Media type application/hl7-v2 · extension .hl7 · category Data
Generate a .hl7 file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about HL7 files
What identifies a .hl7 file?
Nothing at the start of the file does. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
What can go inside the HL7 file?
There are 3 content options for .hl7: Lab result (ORU), Admission (ADT), Order (ORM). For HL7 these are alternatives, so pick the one matching what you need to test.
Can I download several broken HL7 files at once?
Yes, select more than one File Condition and you get one ZIP containing a .hl7 per condition, each named after its condition.
Can the HL7 file use UTF-16 or a byte-order mark?
Yes. .hl7 is a text format, so it can be generated as UTF-8, UTF-8 with a byte-order mark, UTF-16 LE or UTF-16 BE. The body is shortened before re-encoding so the finished file still lands on the exact size you asked for. Note that a UTF-16 file always has an even byte count.
How do I open or verify the HL7 file?
Open it in any text editor, but note the segments are separated by a bare carriage return, so editors that expect Windows or Unix line endings may show it as one long line. HL7 Inspector, 7Edit or a Mirth Connect channel will parse it properly.