NEW!

HL7 to JSON Converter

Convert HL7 v2.x messages to clean JSON instantly. Choose simplified or HAPI-style output, copy or download, all in your browser. No data leaves your device.

HIPAA-Compliant by Design

Your medical data never leaves your device. No PHI is transmitted to any server.

HIPAA-Friendly No PHI Transmission Local Processing

All processing happens locally in your browser. Your HL7 messages and PHI never leave your device. HIPAA-compatible.

Drop .hl7 or .txt file here, or paste below

Output mode:
Examples:

Keywords

HL7 to JSON, HL7 v2 JSON, HL7 JSON converter, HL7 2.x JSON, parse HL7 JSON, HL7 message parser JSON

Need something else?

How to use

1

[object Object]

2

[object Object]

3

[object Object]

4

[object Object]

5

[object Object]

Features

Two Output Modes

Simplified mode produces readable flat keys (PID.5, OBX.5) ideal for quick inspection. HAPI-style mode emits named component keys (PID.5.FN.1) that mirror the HAPI Java library's JSON serialization β€” useful when comparing against systems that output HAPI JSON.

Full HL7 v2.x Coverage

Handles all standard segment types: MSH, PID, PV1, OBR, OBX, ORC, NTE, NK1, DG1, IN1, GT1, MRG, and more. Parses repeated fields (~ delimiter), components (^ delimiter), and subcomponents.

HL7 Escape Sequence Resolver

Optionally resolves HL7 escape sequences: \F\ β†’ |, \S\ β†’ ^, \T\ β†’ &, \R\ β†’ ~, \E\ β†’ \. Keeps the raw encoded form when unescape is off.

Side-by-Side Comparison

After conversion, view the original HL7 source and resulting JSON in adjacent read-only panes so you can verify field-by-field that the conversion is correct.

Privacy-First Local Processing

All parsing runs in your browser. Your HL7 messages and any PHI they contain never leave your device. HIPAA-compatible and safe for hospital and clinic workstations.

Why Choose This Tool?

PHI Never Leaves Your Device

Unlike cloud-based converters, this tool runs entirely in your browser. No message content, patient identifiers, or PHI is transmitted. You can use it on an air-gapped workstation or behind a hospital firewall without risk.

Two Modes for Two Workflows

Simplified mode is best for quick field lookups and building lightweight ETL rules. HAPI-style is best when you are integrating against a Java HAPI-based system and need to match its JSON output format β€” saves re-implementation work.

Handles Real-World Messages

HL7 v2.x messages in production use inconsistent carriage returns, missing trailing fields, and repeated segments. The parser handles all these edge cases so you get valid JSON even from non-ideal inputs.

Part of an Integrated HL7 Toolchain

Pair with the HL7 Viewer for segment-level inspection, the Segment Browser for field definitions, and the ACK Generator to simulate responses. A complete HL7 workflow without leaving the site.

Understanding HL7 v2.x to JSON Conversion: A Guide for Integration Analysts

Why Convert HL7 v2.x to JSON?

HL7 v2.x is a pipe-delimited, positional text format designed in the late 1980s. Its structure is precise but opaque to modern tooling: most REST APIs, NoSQL stores, ETL pipelines, and analytics platforms expect JSON. Converting HL7 messages to JSON unlocks them for SQL queries, JavaScript processing, Python data analysis, and storage in document databases like MongoDB or Elasticsearch β€” without modifying downstream systems.

Anatomy of an HL7 v2.x Message

An HL7 v2.x message is a carriage-return-delimited sequence of segments. Each segment starts with a three-character name (MSH, PID, OBX). Fields within a segment are separated by the field separator character (usually |). Fields may contain components separated by ^, subcomponents separated by &, and repetitions separated by ~. The MSH segment's first two fields establish these encoding characters, so a compliant parser reads them dynamically rather than hard-coding |^~\&.

Simplified Mode: Fast, Flat, Readable

In simplified mode, the converter emits one JSON object per segment occurrence, with field values keyed as SEG.N (e.g., PID.5 for the patient name field). Single-value fields become strings; fields with components become arrays. This format is easy to index in any document store and straightforward to query with jq or Python's json module. It trades component-key verbosity for readability.

HAPI-Style Mode: Component-Named for System Integration

HAPI (HL7 Application Programming Interface) is the most widely used Java library for HL7 v2.x processing. When HAPI serializes a message to JSON, it names the components using the HL7 data-type descriptor β€” so rather than PID.5[0] you get {"FN":{"surname":"Smith"},"given":"John","middleInitialOrName":"A"}. Systems that emit or consume HAPI JSON (Epic Bridges, Rhapsody channels, Ensemble adapters) produce or expect this shape. If you are building a system that must match HAPI's output, selecting HAPI-style mode saves hours of re-implementation.

Field Repetitions and Occurrence Tracking

HL7 segments can repeat β€” an ORU^R01 result message may have dozens of OBX segments, each carrying a different lab measurement. The converter assigns an occurrence index to repeated segments so OBX[1], OBX[2], OBX[3] stay distinct in the JSON output. Field repetitions (multiple values within one field, separated by ~) are preserved as arrays rather than collapsed into the first value.

Escape Sequences and Unicode

HL7 v2.x uses a backslash escape mechanism to represent the five reserved encoding characters within field values: \F\ for the field separator (|), \S\ for the component separator (^), \R\ for the repetition separator (~), \T\ for the subcomponent separator (&), and \E\ for the escape character itself (\). When the unescape option is enabled, the converter resolves these to their literal characters in the JSON output. Keep it disabled when you need a round-trip-safe JSON representation that can be converted back to HL7 without data loss.

Null and Empty Fields

In HL7 v2.x, an empty field (||) means "not provided" and a double-quote field (|""|) means "explicitly delete the previous value". The converter maps empty fields to JSON null to distinguish them from absent fields β€” a difference that matters when using the JSON to perform database updates where a null should overwrite an existing value but absence should leave it unchanged.

Performance for Large Messages

HL7 v2.x messages are typically small β€” a few hundred bytes to a few kilobytes. Even a complex ORU^R01 with 50 OBX segments converts in under a millisecond in any modern browser. Batch files (multiple messages concatenated in a single file) are not yet supported by this tool, which expects a single message per conversion. For batch processing, split the file on MSH lines and convert each message separately.

Integration Use Cases

Common integration patterns that benefit from HL7-to-JSON conversion include: feeding HL7 demographics (PID, PV1) into a REST-based master patient index; populating Elasticsearch with lab results (OBX) for analytics; testing FHIR conversion logic by first parsing the source HL7 message to JSON then mapping JSON paths to FHIR resource fields; and logging messages in structured form to CloudWatch or Datadog where pipe-delimited text is not searchable.

Round-Trip Fidelity

For integration purposes, JSON is typically an intermediate form that does not need to reconstruct the original HL7 message. However, if round-trip fidelity is required β€” generating HL7 from JSON β€” you must preserve null fields (do not omit them), preserve repetitions as ordered arrays, and keep escape sequences encoded (disable the unescape option). Simplified mode is less suited for round-trips because it omits component names; HAPI-style mode preserves enough structure for reconstruction with a compliant library.

Frequently Asked Questions

Does this tool send my HL7 data to a server?

No. All processing runs in your browser using JavaScript. No message content, PHI, or patient data is transmitted. You can verify this in your browser's developer tools network tab.

What is the difference between Simplified and HAPI-style modes?

Simplified mode keys fields as SEG.N (e.g., PID.5) and represents components as arrays β€” easy to read and query. HAPI-style mode uses named data-type component keys (e.g., PID.5.FN.1) that mirror the HAPI Java library's JSON output, which is useful when integrating with Java-based systems.

What HL7 versions are supported?

HL7 v2.x (v2.1 through v2.9). The parser reads encoding characters from MSH-1 and MSH-2, so it handles any v2.x version without requiring a version selector.

Can I convert a file with multiple HL7 messages?

Not yet. The tool expects a single message per conversion. For batch files, split on the MSH line and convert each message individually.

What does the 'Unescape HL7 sequences' option do?

It resolves HL7 backslash escape sequences to their literal characters: \F\ β†’ |, \S\ β†’ ^, \T\ β†’ &, \R\ β†’ ~, \E\ β†’ \. Keep it off if you need a round-trip-safe JSON that can be re-encoded back to HL7.

How are repeated segments handled?

Repeated segments (e.g., multiple OBX in an ORU result) are emitted as separate objects in the segments array with an 'occurrence' counter. Simplified mode also groups them by segment name with indexed keys.

How are null fields represented in the JSON?

Empty fields (||) appear as JSON null, and empty components of non-empty fields appear as null array entries. This preserves the semantic distinction between 'not provided' and 'absent'.

Can I use the JSON output to reconstruct the original HL7 message?

HAPI-style mode preserves enough structure for reconstruction with a compliant library. Simplified mode loses component names, so round-trip reconstruction is not reliable. Disable the unescape option to keep escape sequences intact.

Is this tool HIPAA compliant?

The tool's privacy design (local processing, no data transmission) is consistent with HIPAA's technical safeguard requirements. However, compliance also depends on your workstation security, browser configuration, and organizational policies β€” consult your compliance officer.

What happens if I paste an invalid HL7 message?

The parser checks for a valid MSH segment and correct encoding characters. If validation fails, an error message is shown explaining what went wrong. No partial JSON is emitted to avoid silently incorrect output.

Learn more