Hex Editor Tool
The Hex Editor is a built-in tool in HL7Spy that lets you view and edit the raw bytes of a file or HL7 message in a side-by-side hexadecimal / ASCII layout. It is most commonly used to:
Inspect the exact bytes that make up a message, including non-printable characters, line endings (CR, LF, CRLF), and encoding markers such as BOMs.
Diagnose framing issues (MLLP start/end blocks, segment separators, embedded nulls, etc.).
Locate and jump to a specific byte offset in a large file.
Make small targeted byte-level corrections to a file and save them.
Tip
The Hex Editor is intentionally a low-level tool. If you just want to read or edit the content of an HL7 message, use the standard Message Editor. Use the Hex Editor when you need to see or change the underlying bytes.
Opening the Hex Editor
There are several ways to open the Hex Editor, depending on what you want to inspect.
1. Open an arbitrary file in the Hex Editor
On the ribbon, click Open Hex in the File Operations group.
Pick a file from the Open File dialog.
The default filter shows *.hl7, *.txt and *.log files, but you can switch to All files (\.\) to open any file on disk.
You can also:
Press the Ctrl keytip for the Open Hex button (H) when the ribbon is active.
Click the drop-down arrow next to Open Hex to pick a recently opened hex file from the Recent Hex Files list.
Drag and drop a single file onto the Hex Editor window.
2. Inspect the current HL7 message as hex (read-only)
From an open message in the Message Editor:
Select the field, segment, or range of text you want to inspect (optional).
Open Message Properties (which launches the Hex Editor view of the current message).
The Hex Editor opens in read-only mode with the underlying message bytes loaded. If the message still maps to a file on disk and has not been modified, the editor opens the file directly and highlights the current selection (field or manually selected range). If the message has been modified in memory, the editor shows a snapshot of the in-memory bytes and the status bar displays:
Message has been modified by the user
3. Hex Editor from the Open Folder view
From the Open Folder tool:
Right-click on any file in the file list.
Choose the option to open the file in the Hex Editor.
The Hex Editor window
The window is divided into three regions:
Region | Location | Purpose |
|---|---|---|
Toolbar | Top of the window | Save, revert, clipboard, search, navigation, and bytes-per-line controls. |
Hex view | Center of the window | Offsets on the left, hex bytes in the middle, and the ASCII "string view" on the right. |
Status bar | Bottom of the window | File size, current line / column, hex preview, progress bar (during searches), and the current offset / file size with a hex / decimal toggle. |
Hex view layout
Line offsets (left column) show the byte offset of the first byte on each line.
Hex bytes (middle column) show the bytes in hexadecimal. You can edit bytes in place by clicking a byte and typing two hex digits.
String view (right column) shows the ASCII interpretation of the same bytes. Non-printable bytes are shown as a placeholder character. You can also type directly into the string view to replace bytes.
Group separators and a column header (column numbers 0-F, 0-17, etc.) are shown above the hex area to make alignment easier.
Tip
Click anywhere in the hex area or the string view to move the caret. The other column automatically scrolls to the matching position.
Toolbar reference
The toolbar at the top of the Hex Editor exposes the most common actions.
Button | What it does |
|---|---|
Save | Writes any pending edits back to the underlying file. Only enabled when there are unsaved changes. |
Revert | Discards all unsaved edits and reloads the file from disk. Only enabled when there are unsaved changes. The Ctrl+Z shortcut is bound to this command. |
Cut | Cuts the currently selected bytes to the clipboard. Disabled when there is no selection or when the editor is read-only. |
Copy | Copies the currently selected bytes to the clipboard. |
Paste | Pastes bytes from the clipboard at the current caret position. Disabled when the editor is read-only or when the clipboard does not contain compatible data. |
Find | Opens the Find dialog. |
Find Next | Continues the previous search from the current position. If no search has been defined yet, opens the Find dialog first. |
Go To | Opens the Go To dialog, which jumps the caret to a specific byte offset. |
Auto | Automatically chooses the number of bytes per line based on the current window width. This is the default. |
16 Byte | Forces the view to 16 bytes per line. |
24 Byte | Forces the view to 24 bytes per line. |
32 Byte | Forces the view to 32 bytes per line. |
Note - Read-only files and messages
When a file is opened read-only (because the file is locked, marked read-only on disk, or because the Hex Editor was launched from Message Properties), the Save, Revert, Cut and Paste buttons remain disabled. You can still search, navigate, and copy bytes.
Status bar reference
The status bar at the bottom of the window shows live information about the file and caret.
Field | Meaning |
|---|---|
File size | Total size of the open data, shown with a human-readable unit (for example 1,245 bytes or 3.4 MB). |
Position | The current Ln (line) and Col (column within the line) of the caret. The column is 1-based and uses the currently selected bytes-per-line setting. |
Hex preview | Up to the next 8 bytes starting from the caret, shown as hex pairs. Useful for quickly reading a multi-byte value without selecting it. |
Progress bar | Appears on the right only while a long-running Find is in progress. |
Offset / Size | Shows the current byte offset (1-based) and the total file size. Click the drop-down arrow to switch between Decimal (for example |
Finding bytes or text
Click Find or press Ctrl+F to open the Find dialog.
The dialog has two search modes that are selected automatically based on which field you are typing in:
Text - type a string in the Text box. By default the search is case-insensitive. Tick Match Case to make it case-sensitive.
Hex - type a sequence of hex bytes in the Hex box (for example
0D 0A 0Bor0d0a0b). The search is byte-exact.
Clicking OK starts the search from the current caret position and selects the next match. If no match is found, the message End of File Reached is shown.
Finding subsequent matches
After the first match, press F3 (or click Find Next) to find the next occurrence without re-opening the dialog.
Find Next reuses the last entered search, so you can keep stepping through all hits.
Cancelling a long search
Searching a very large file can take several seconds. While the search is running:
A progress bar appears on the right side of the status bar.
Press Escape to abort the search.
Inside the Find dialog, click Cancel while the search is running to abort it.
Jumping to a specific offset
Click Go To or press Ctrl+G to open the Go To dialog. Enter a byte number and click OK (or press Enter).
The value is 1-based: entering 1 jumps to the first byte of the file. The maximum accepted value is the file size. The default value shown in the dialog is the current caret position, so you can quickly adjust to a nearby offset.
Editing bytes
When the file is writable:
Click the byte you want to change (in either the hex or the string column).
Type the replacement value:
In the hex column, type two hex digits.
In the string column, type a printable character.
Use Cut, Copy, and Paste for larger edits.
The title bar and the Save button reflect pending changes. Use Save to commit changes to disk, or Revert / Ctrl+Z to discard all changes and reload the file.
Closing with unsaved changes
If you close the Hex Editor while there are unsaved changes, HL7 Spy prompts:
Yes - Save changes and close.
No - Discard changes and close.
Cancel - Return to the editor with changes intact.
Keyboard shortcuts
Shortcut | Action |
|---|---|
Ctrl+F | Open the Find dialog. |
F3 | Find next occurrence of the last search. |
Ctrl+G | Open the Go To dialog. |
Ctrl+Z | Revert all unsaved changes (reloads the file). |
Escape | Cancel a search that is currently in progress. |
Ctrl+H | From the main HL7 Spy window, launches the Open Hex command. |
Standard text-editing shortcuts also work in the hex view:
Shortcut | Action |
|---|---|
Ctrl+C | Copy selected bytes. |
Ctrl+X | Cut selected bytes (writable files only). |
Ctrl+V | Paste bytes at the caret (writable files only). |
Arrow keys | Move the caret. |
Shift + Arrow / Click | Extend the selection. |
Page Up / Page Down | Scroll a full page. |
Home / End | Jump to the start or end of the current line. |
Ctrl+Home / Ctrl+End | Jump to the start or end of the file. |
Appearance and layout
Bytes per line can be set to Auto (default), 16, 24, or 32 via the toolbar. Auto adjusts as you resize the window.
The Hex Editor respects the currently selected HL7 Spy theme. When you change the application theme, the editor colors update automatically.
The monospace font used by the hex view is fixed at runtime to keep columns aligned.
Tips and gotchas
Tip - Use Hex Editor to spot hidden characters
Segment terminators in HL7 are carriage returns (
0x0D). The Hex Editor makes it obvious when a file usesCRLF(0x0D 0x0A) instead ofCRonly, or when stray whitespace / BOM bytes have been added by another tool.
Warning - Large files
For very large files, switching to 16 Byte or 24 Byte mode can make the file easier to scan visually, and keeps the line count predictable. Searches on multi-gigabyte files can take a while - watch the progress bar and remember that Escape cancels the search.
Note - Read-only when launched from a message
When the Hex Editor is launched from Message Properties, it is always read-only, even when the underlying file is writable. This is by design, to prevent accidental edits while inspecting a message. To edit the underlying file, close that window and reopen it using Open Hex from the ribbon.