HL7 to JSON Converter
Paste an HL7 v2 message and get JSON you can feed to a script. Nothing is uploaded.
HL7 message
JSON
Paste your HL7 on the leftabove and the JSON shows up here.
Or drop a file on this box, , or .
Why convert HL7 to JSON
Pipe-delimited HL7 v2 is fine for interface engines and awkward for everything else. The moment you want to check a feed in a notebook, write a test fixture, or diff two messages, you end up writing yet another split-on-pipe script and getting MSH wrong. This HL7 to JSON converter does the parsing for you: paste a message and the right pane shows one JSON object per segment, with the field position and a short name in each key, such as "PID.5 patient_name".
The parser follows the HL7 v2 message rules that trip up home-made scripts. It takes the separators from MSH-1 and MSH-2 instead of assuming |^~\&, numbers MSH fields correctly (the pipe after MSH is MSH-1), turns repetitions into arrays and components into nested objects, and decodes escape sequences such as \F\ and \.br\. Segments may end in \r, \n or \r\n, and MLLP framing bytes from a capture are ignored.
Every value comes out as a JSON string, exactly as written. Nothing is turned into a number, so MRN 00048213, a result of 5.40 and a timestamp keep their exact text, which is what JSON strings are for. The conversion runs in your browser and the message is not sent to a server. To browse the JSON afterwards, paste it into our JSON parser and it shows up as a table.
How to convert an HL7 message to JSON
Paste the message
Paste one or more messages into the left pane, upload a .hl7 or .txt file, or drop it onto the tool. Sample loads a fictional ORU^R01 lab result with three OBX results.
Pick the key style
Named fields gives keys with a short name after the position, which reads well when you are exploring. Positions only gives PID.5 and PID.5.1, which is easier to address from code and does not change if we ever rename a field. Empty fields are left out unless you press Keep empty fields. This line:
PID|1||48213^^^RIVERSIDE^MR||Marsh^Elena^K||19880412|F becomes this with Named fields:
{
"segment": "PID",
"PID.1 set_id": "1",
"PID.3 patient_identifier_list": {
"PID.3.1 id_number": "48213",
"PID.3.4 assigning_authority": "RIVERSIDE",
"PID.3.5 identifier_type_code": "MR"
},
"PID.5 patient_name": {
"PID.5.1 family_name": "Marsh",
"PID.5.2 given_name": "Elena",
"PID.5.3 second_or_middle_name": "K"
},
"PID.7 date_time_of_birth": "19880412",
"PID.8 administrative_sex": "F"
} Copy or download
The status line under the message shows the HL7 version, the message type and any warnings by line (an empty MSH-9, a wrapped line that does not start with a segment ID). Copy puts the JSON on your clipboard, Download saves it as hl7-message.json.
What people use HL7 to JSON for
Test fixtures from real traffic
Take a de-identified message from the engine log, convert it, and assert on "PV1.19 visit_number" in your tests instead of on a pipe count.
Checking lab feeds in a notebook
Load the JSON of an ORU^R01 and pull the OBX codes, values and units into a dataframe. OBX-3 usually carries a LOINC test code, so the results line up with your reference tables.
Groundwork for a FHIR mapping
Seeing every filled field as a JSON key makes it easier to plan which ones go where. The official v2 to FHIR mappings describe the targets segment by segment.
Explaining a message to someone new
Named keys turn Marsh^Elena^K into family, given and middle name. For someone joining an integration team, that is a quicker start than the background on the HL7 Wikipedia page alone.
Frequently Asked Questions
What does the JSON look like for a batch with several messages?
One message gives one object with message_type, version, control_id and a segments array. Two or more messages give {"messages": [...]}, and FHS/BHS/BTS/FTS batch segments go in batch_segments. Segments keep their order, so three OBX segments are three entries in the array.
How are repetitions and components written?
A field with one value is a string. A field with components becomes an object keyed by component position (PID.5.1, PID.5.2), and subcomponents nest one level further (PID.3.4.1). A field with repetitions (the ~ separator) becomes an array, one entry per repetition, keeping empty repetitions so positions do not shift.
Why are numbers and dates kept as strings?
Because HL7 v2 is text and the exact text matters. Converting 00048213 to a number drops the zeros, and a long account number would lose digits. Dates stay in HL7 form (20261203091500-0800) so nothing is guessed about time zones. Escape sequences are decoded, so Smith \T\ Sons comes out with the real subcomponent character.
Does it handle custom encoding characters and Z-segments?
Yes. The separators come from each message's MSH-1 and MSH-2, so a feed using # or ! works. Z-segments and other segments we have no names for are converted by position, for example "ZPI.3".
Is the message uploaded anywhere?
No. The parser runs in your browser and the page does not send your message to a server. Still, treat real patient data the way your organization requires, and prefer de-identified samples when you can.
Can I see the message as a table instead?
Use the HL7 viewer. It shows the same message as one row per field with names and readable dates, and has a Copy as JSON button that gives the same JSON as this page.
Related tools
Read the message field by field, or work with the JSON you got.