Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

View Edit Hexadecimal Mac: How to Open and Change Hex Files

· 7 min read · Home Tech

In this article
  1. What Is a Hexadecimal File and Why Edit It?
  2. Built-in Command Line Tools: xxd and hexdump
  3. How to Edit Hex with xxd (Terminal Method)
  4. Free GUI Hex Editors for Mac
  5. How to Choose the Right Tool for Your Task
  6. Common Problems and How to Avoid Them
  7. Safety and Accuracy: Working with Binary Data
  8. Alternatives to Hex Editing
  9. Frequently Asked Questions

To view or edit hexadecimal data on a Mac, you need a dedicated hex editor or a command-line tool like xxd or hexdump, because the built-in TextEdit and Preview cannot interpret raw hex. This guide covers the built-in terminal tools, free GUI hex editors, and step-by-step instructions for both viewing and editing hex files safely.

What Is a Hexadecimal File and Why Edit It?

Hexadecimal (hex) is a base-16 numeral system used to represent binary data in a human-readable form. Each hex digit represents four binary bits, so a byte (8 bits) is exactly two hex characters (e.g., FF = 255). Files on your Mac—images, executables, documents—are stored as binary data, and a hex editor lets you see the raw bytes that make up the file, rather than the interpreted content you see in normal apps.

You might need to view or edit hex when:

  • Debugging a corrupt file header or footer
  • Inspecting a file to verify its magic number (e.g., FF D8 for JPEG, 89 50 4E 47 for PNG)
  • Patching a binary executable or firmware
  • Analyzing network captures or raw disk images
  • Learning how files are structured internally

Editing hex is risky—a single wrong byte can make a file unreadable—so always work on a copy.

Built-in Command Line Tools: xxd and hexdump

Every Mac includes xxd and hexdump in the terminal (found in /usr/bin). These are the quickest way to view hex without installing anything.

To view a file in hex with xxd:

  1. Open Terminal (Finder > Applications > Utilities > Terminal).
  2. Type xxd /path/to/file and press Return.
  3. The output shows the byte offset (in hex), the hex bytes, and the ASCII representation on the right.

For example, xxd myfile.bin might output:

00000000: 5468 6973 2069 7320 6120 7465 7374 2e This is a test.

To limit the output to the first N bytes, use xxd -l 256 file. To view in a more compact format, hexdump -C file shows hex and ASCII side by side. Both tools are read-only by default—they do not modify the file.

How to Edit Hex with xxd (Terminal Method)

Editing hex with xxd requires converting the file to a hex dump, editing the text, then converting back. This is a two-step process:

  1. Create a hex dump: xxd file.bin > file.hex
  2. Open file.hex in any text editor (e.g., nano, vim, or TextEdit).
  3. Edit the hex bytes—be careful to keep the same number of characters per line, or the conversion will fail.
  4. Convert back: xxd -r file.hex > newfile.bin

For example, to change the first byte of a file from 00 to 01, you would edit the dump and then run the reverse command. The -r flag tells xxd to interpret the hex dump as binary. This method works but is clumsy for large files; a GUI hex editor is better for serious work.

Free GUI Hex Editors for Mac

For visual editing, several free and open-source hex editors run natively on macOS. These tools show the hex bytes in one column and the ASCII interpretation in another, and they let you edit either side directly.

  • Hex Fiend – The most popular free hex editor for Mac. It is fast, supports large files (gigabytes), and integrates with the macOS file system. You can download it from its official site or via Homebrew (brew install --cask hex-fiend).
  • 0xED – Another free hex editor that supports plugins and a clean interface. It is older but still works on current macOS versions.
  • Synalize It! – A more advanced tool with a free “personal” edition. It can parse structured binary data using templates, which is useful for file formats with known layouts.

To edit with Hex Fiend:

  1. Open Hex Fiend and drag a file into the window.
  2. Click on a hex byte and type the new value (it accepts 0-9 and A-F).
  3. Press Cmd+S to save. The file is immediately overwritten.

Always keep a backup before editing, because Hex Fiend does not keep an undo history after you close the file.

How to Choose the Right Tool for Your Task

The best tool depends on what you are doing:

  • Quickly inspect a file header – Use xxd or hexdump in Terminal. No installation needed.
  • Edit a few bytes in a small file – Use xxd -r or a GUI editor like Hex Fiend.
  • Edit a large binary (e.g., firmware, disk image) – Use Hex Fiend because it handles large files without loading them entirely into memory.
  • Reverse-engineer a file format – Use Synalize It! with a template, or Hex Fiend for manual inspection.
  • Scripted/automated edits – Use xxd in a shell script, or a Python script with the bytes type.

For most users, Hex Fiend is the sweet spot: free, reliable, and easy to learn.

Common Problems and How to Avoid Them

Editing hex can break files if you are not careful. Here are the most frequent issues and how to avoid them:

  • Changing file length – If you add or remove bytes, the file size changes. Some formats (like executables) have internal offsets that become invalid. Only change bytes in place unless you know what you are doing.
  • Wrong endianness – Multi-byte integers can be stored little-endian (least significant byte first) or big-endian. On Intel/ARM Macs, the CPU is little-endian, but file formats vary. For example, the PNG width is stored big-endian. Check the format spec before editing.
  • Accidental ASCII editing – In GUI editors, clicking on the ASCII column and typing will overwrite the corresponding hex bytes. This is often unintended.
  • Forgetting to backup – A hex editor has no “undo” after saving. Always copy the file first (cp file file.bak).
  • Using TextEdit to edit a hex dump – TextEdit may add formatting or smart quotes, corrupting the dump. Use a plain text editor like nano or BBEdit in plain-text mode.

Safety and Accuracy: Working with Binary Data

Hex editing is inherently risky because you are manipulating the raw data that the system reads. A single wrong byte can make a file unopenable, crash an application, or even prevent your Mac from booting if you edit a system file. Follow these rules:

  • Never edit system files (in /System, /Library, or /usr) unless you are absolutely certain and have a full backup.
  • Always work on a copy of the file, not the original.
  • Verify the file’s checksum before and after editing (e.g., shasum -a 256 file).
  • If you are patching an executable, ensure the new bytes are the same length as the original, or the binary may be rejected by the operating system’s code signing.
  • For firmware updates, use the manufacturer’s official tools—manual hex edits can brick the device.

If you only need to view hex, prefer read-only commands like xxd to avoid accidental modification.

Alternatives to Hex Editing

Hex editing is not always the best way to achieve your goal. Depending on the task, consider these alternatives:

  • Text editors for text-based formats – If the file is actually a text file (like JSON, XML, or a .plist), use a code editor like VS Code or Xcode. Editing in hex is error-prone for text.
  • Property List Editor – For macOS plist files, use the built-in Xcode or plutil command to edit in a structured way.
  • Binary file parsers – For known formats (e.g., PNG, JPEG, ZIP), use a library in Python or a dedicated tool like pngcheck to validate or modify specific fields.
  • Disk utility or dd – To edit raw disk images, use dd to copy specific blocks, or mount the image and edit the files inside normally.
  • Hex viewers in other apps – Some file managers (like ForkLift) include a hex view pane, but they do not allow editing.

Choose the simplest tool that safely accomplishes the task—hex is powerful, but it is a last resort for most users.

Frequently Asked Questions

Can I view hex in TextEdit?

No. TextEdit interprets files as text, so a binary file will show garbled characters or be rejected. You need a hex editor or a terminal tool.

Is there a built-in hex editor on Mac?

No. macOS does not include a GUI hex editor. However, the terminal commands xxd and hexdump are built-in and can view hex. For editing, you must install a third-party tool.

How do I convert a hex dump back to a binary file?

Use xxd -r dump.hex > output.bin. This reverses the xxd output. Ensure the dump was created with xxd (not hexdump) for compatibility.

What is the difference between xxd and hexdump?

Both display hex, but xxd is simpler and can also convert back to binary with -r. hexdump -C shows a similar output but has more formatting options. For editing, xxd is preferred because of the reverse function.

Can I edit a file without changing its size?

Yes, if you only overwrite existing bytes. Adding or deleting bytes changes the file size and may break internal offsets. Most hex editors allow in-place editing by default.

Why does my hex editor show both hex and ASCII?

Because binary data often contains printable text sequences. Showing ASCII helps you identify strings inside the file. The hex column is the actual byte values; the ASCII column is the same bytes interpreted as characters.