Editing a binary file requires a hex editor instead of a plain text editor — hex editors show raw bytes and let you edit individual values without corrupting the data.
Whether you need to patch a saved game, tweak firmware, or inspect a data file, this guide covers how to edit a binary file safely across every major platform. The first rule is simple: never open a binary file in a normal text editor. Saving from one will scramble the original structure beyond recovery. Hex editors are the correct tool, and the sections below walk through the best options for Windows, Linux, macOS, and the web.
What Is a Binary File and Why Can’t You Use a Normal Text Editor?
Binary files store data as raw bytes — sequences of 0s and 1s grouped into 8-bit values — rather than human-readable characters. When a standard text editor opens a binary file, it tries to interpret every byte as a letter, symbol, or control character. Most bytes fall outside the printable ASCII range, so the editor either shows garbage, silently replaces values, or — worst case — rewrites the file in its own encoding when you hit Save. That one save can destroy checksums, offsets, and embedded structures that the original program depends on.
Hex editors avoid this problem by displaying each byte as a two-digit hexadecimal value alongside a side panel showing the ASCII representation. You see exactly what is in the file, and you change only the bytes you intend to change. No hidden reformatting, no encoding conversions.
Editing a Binary File on Linux: Tools and Commands
Linux offers several battle-tested hex editors, both graphical and terminal-based. The workflow is the same across all of them: open the file, navigate to the target offset, overwrite the bytes you need to change, and save without altering anything else.
GNOME Hex Editor (ghex)
ghex is the standard graphical hex editor for GNOME-based Linux desktops. Install it with sudo apt install ghex (Debian/Ubuntu) or the equivalent command for your distribution. Open a file with ghex sample.bin, edit bytes by clicking on a hex cell and typing the new value, then press Ctrl+S to save. The ASCII panel on the right updates in real time, so you can spot plain-text strings embedded in the binary.
hexedit (Command Line)
hexedit is a lightweight terminal hex editor that works over SSH or on minimal systems. Install it with sudo apt-get install hexedit. Navigation uses arrow keys, and editing works in overwrite mode — move the cursor to a byte position, type the new hex digits, and press Ctrl+X to save. Because it runs entirely in the terminal, hexedit is useful for quick edits on remote servers.
Vim with xxd
Vim can edit binary files when used with the xxd utility, which converts a binary file into a hex dump and back. Open the file with vim -b sample.bin, then run :%!xxd to convert the file into a readable hex dump. Edit the hex values directly, then run :%!xxd -r to reverse the transformation before saving with :wq. Forgetting the xxd -r step is the most common mistake — it leaves the file as a hex dump instead of restoring the original binary.
How Do You Edit a Binary File on Windows?
Windows users have solid options ranging from Microsoft’s own tool to third-party editors built for large or complex binary files.
Visual Studio Binary Editor
Microsoft’s Binary Editor is part of Visual Studio and Visual Studio C++ and lets you edit any resource at the byte level in hexadecimal or ASCII format. To open a new file, go to File > New > File, choose the file type, then use the drop-down arrow next to Open and select Open With > Binary Editor. For an existing file, use File > Open > File, select the file, then choose Open With > Binary Editor. Select a byte and type the new value — the change appears immediately in both the hex and ASCII panes. You can also search for ASCII strings or their hex equivalents, for example Hello or 48 65 6C 6C 6F. The Binary Editor is ideal for developers who already work inside Visual Studio, but it does require a Visual Studio installation and is not a general-purpose repair tool for all binaries.
Free Hex Editor Neo
Free Hex Editor Neo is a Windows-native binary editor optimized for large files. It supports big-file handling, pattern-based searches, and undo/redo. The free tier covers basic hex editing, while the paid version adds advanced features like disk editing and data comparison. It is a strong choice if you work with firmware images or multi-gigabyte binary dumps.
UltraEdit
UltraEdit includes a full hex-editing mode alongside its text-editor features, supporting DLLs, executables, and .bin files. It runs on Windows, macOS, and Linux, making it a cross-platform option for users who already depend on UltraEdit for code editing. The hex mode toggles on and off, so you can switch between text and byte-level views within the same session.
Cross-Platform and Browser-Based Hex Editors
When you need to edit a binary file on macOS or switch between operating systems frequently, browser-based and Java-based editors fill the gap without requiring installation.
HexEd.it
HexEd.it is a free browser-based hex editor that runs on any modern OS with a web browser. It uses HTML5 and JavaScript, so no data is sent to a server — everything happens locally in the browser tab. Open a file by dragging it into the browser window, edit bytes in the hex grid, and save the modified binary to your machine. Because it is browser-based, it works on Windows, macOS, Linux, and Chromebooks, though it may not be suitable for sensitive files under strict air-gap policies.
BinEd
BinEd is a free, open-source hex viewer and editor written in Java. It runs on any platform with a Java runtime. The interface is simple: open a file, scroll to the offset you need, and edit. BinEd is useful when you need a lightweight tools that works identically across Windows, macOS, and Linux without a browser dependency.
Hex Editor Tools at a Glance
| Tool | Platform | Best For |
|---|---|---|
| GNOME Hex Editor (ghex) | Linux | Graphical hex editing on GNOME desktops |
| hexedit | Linux, macOS | Terminal-based quick edits over SSH |
| Vim + xxd | Linux, macOS, Unix | Power users already comfortable in Vim |
| Visual Studio Binary Editor | Windows | Developers using Visual Studio |
| Free Hex Editor Neo | Windows | Large binary files and firmware images |
| UltraEdit | Windows, macOS, Linux | Users who want a combined text + hex editor |
| HexEd.it | Web (any OS) | No-install, cross-platform browser editing |
| BinEd | Java (cross-platform) | Stand-alone Java-based editor |
| VS Code HexEditor Extension | Windows, macOS, Linux | VS Code users who want inline hex editing |
Common Mistakes and How to Avoid Them
Even with the right tool, a few recurring mistakes can corrupt a binary file or waste time. The table below lists the most common pitfalls and how to sidestep each one.
| Mistake | Consequence | Prevention |
|---|---|---|
| Using a plain text editor | File structure gets corrupted on save | Always use a hex editor for binary files |
| Editing without a backup | Irrecoverable data loss if the edit breaks the file | Copy the original file before making any changes |
| Forgetting xxd -r before save in Vim | File remains a hex dump, not the original binary | Always run :%!xxd -r before :wq |
| Inserting or deleting bytes instead of overwriting | Shifts all subsequent data, breaking offsets and checksums | Only overwrite bytes — never use insert or delete modes |
| Assuming every .bin file is the same format | Wrong tool or interpretation of the data | Identify the file type (ROM dump, firmware, archive, etc.) before editing |
| Not verifying the file after editing | Silent corruption goes unnoticed | Reopen the file in the hex editor and test it in its target application |
| Changing bytes without understanding the format | Broken checksums, headers, or embedded structures | Research the file format or use a format-aware tool when available |
Safe Workflow for Editing Any Binary File
- Back up the original file. Copy the binary to a separate location so you can roll back if something goes wrong.
- Identify the file format. A
.binextension can mean anything — firmware, ROM dump, archive, disk image, or proprietary data. Understanding the format tells you which sections are safe to edit and which contain checksums or offsets that need to be updated afterward. - Open the file in a hex editor appropriate for your operating system. Use one of the tools listed above — never a word processor or default text editor.
- Locate the bytes you need to change by searching for known ASCII strings or hex patterns. In the Visual Studio Binary Editor you can search for
Helloor48 65 6C 6C 6F; in ghex or hexedit you navigate by offset. - Overwrite only the intended bytes — do not insert or delete. Changing the file length or shifting data downstream will almost certainly break the file.
- Save and verify. Reopen the file in the hex editor to confirm your changes are correct, then test it with whatever application normally reads that binary format.
Following this sequence keeps your edits precise and reversible, regardless of which tool or platform you are using.
References & Sources
- Microsoft Learn. “Binary Editor (C++)” Official documentation for Visual Studio’s built-in byte-level editor.
