9

I have a hex file that I am attempting to convert to binary. I have performed this on Linux before using the command:

xxd -r -p mykey.hex > mykey.bin

But I cannot figure out how to do this same command on Windows. I have downloaded a few hex editor tools but not really sure how to use them to convert hex into a binary representation.

Is there a way to do this in Windows, or are there any similar tools out there that would allow me to do this?

| improve this question | |
  • I have attempted the similar once. I succeeded by turning the source into a javascript-escaped string with a regex and unescaping. – Jan Dvorak Nov 1 '12 at 17:22
  • @fixer1234, OP wanted hex-to-binary - not the other way round. Also, the scripts you linked to appear to only produce a hex dump of the binary file. That's OK if it's all you need, but a true hex file is usually in Motorola or Intel hex format, with framing and checksums added. – rossmcm Nov 17 '15 at 22:57
  • So the ge.tt link broke in my answer and I just fixed it. Why did you just change your accepted answer, to an answer that points to unxutils that many including you yourself even saw doesn't contain xxd? Even the author of that answer apologised for his link not having xxd. That is extremely irresponsible. Accepting answers you know are wrong while also not commenting when an issue occurs with an answer, is very irresponsible, I have downvoted you accordingly. If others had known you'd do that they would not have upvoted you. – barlop Nov 6 '18 at 9:14
1

There is a native port of xxd to Win32.

See unxutils here for downloads.

Another source of Win32 ports of common GNU and/or *nix utilities is GnuWin32.

Added By Barlop

This answer is incorrect, see comments, xxd is not in unxutils, and not in gnuwin32 either.

| improve this answer | |
  • I have downloaded this package but I do not see the xxd.exe anywhere in the package.. – Kevin Nov 1 '12 at 17:40
  • My apologies. I swear that's where I fetched it from long ago. – Greg Jandl Nov 1 '12 at 17:44
  • @Kevin, which one did you get and not find it in? It’s not in GnuWin32, it’s in the first paged that Greg linked to, in the table towards the middle of the page (just use your browser’s search function and type xxd). Also, typing xxd into the search-field of the GnuWin32 page brings up the reversable hexdump that it includes. – Synetech Aug 30 '13 at 17:07
  • OK @barlop, I'm really confused. I just downloaded [UnxUtlis.zip] (weihenstephan.de/~syring/win32/UnxUtils.zip) and I can't find xxd in there, or anything else that looks like it might be a hex-to-binary converter. (FWIW I can't get link markup to work either. Not my day). – rossmcm Nov 17 '15 at 22:30
  • @rossmcm I think I was just interpreting synetech and taking what he said as correct..when I commented about it being in unxutils. I've just deleted that comment of mine 'cos it's misleading. Maybe Synetech didn't check either(beyond the webpage that listed). But indeed, I don't see xxd in unxutils either, or in any unxutils that i'd extracted in the past either. – barlop Nov 18 '15 at 0:03
17

VIM 7.x contains xxd for Windows

https://ftp.nluug.nl/pub/vim/pc/gvim73_46_s.zip

C:\Program Files (x86)\Vim\vim74>.\xxd -v
xxd V1.10 27oct98 by Juergen Weigert (Win32)

C:\Program Files (x86)\Vim\vim74>dir xxd.exe
10/08/2013  12:33 PM            70,144 xxd.exe

C:\Program Files (x86)\Vim\vim74>file xxd.exe
xxd.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit

Cygwin has one also

C:\cygwin\bin>.\xxd.exe -v
xxd V1.10 27oct98 by Juergen Weigert

C:\cygwin\bin>dir xxd.exe
18/09/2015  05:44 AM            18,963 xxd.exe

C:\cygwin\bin>file xxd.exe
xxd.exe: PE32+ executable (console) x86-64, for MS Windows
| improve this answer | |
  • note- my old cygwin xxd.exe was "26/08/2014 12:00 AM 17,437 xxd.exe" I doubt even that the diff file size is relevant though. I didn't run the file.exe command on it though I'm sure it was 64 bit 'cos the -v output was the same. Odd that the file size was different, not that it matters. I just updated the answer to have the file.exe command run on it, just to show whether 32 bit or 64 bit though that's shown with the version info anyway with -v. The 32bit one says 32bit with the -v and the 64bit doesn't say 32bit which is meant to imply that it's 64bit since the 32bit xxd -v says 32bit. – barlop Nov 12 '15 at 12:57
  • Chrome blocks xxd.exe from ge.tt/5jfutZq/v/0 as malware. – rossmcm Nov 17 '15 at 23:00
  • @rossmcm chrome is being ridiculous.. you can go to the downloads section in chrome and click "recover malicious file" i.imgur.com/6vBebqL.png Or, get it from cygwin or vim. – barlop Nov 18 '15 at 0:01
  • OK, xxd.exe was only flagged by 1 out of 40 at VirusTotal so I'm happy. Note that it doesn't seem to convert hex files to binary however. I was looking for something that took Intel or Motorola hex files and converted them to a binary image. This hex2bin at SourceForge did the trick. – rossmcm Nov 18 '15 at 6:06
  • 1
2

use powershell format-hex command:

PS C:\path\path\Documents\blah> format-hex Util3.class


           Path: C:\blah\blah\Documents\blah\Util3.class

           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000   CA FE BA BE 00 00 00 34 00 1F 0A 00 07 00 10 09  Êþº¾...4........
etc...
| improve this answer | |
  • This question is about converting a hex dump into a binary, not vice versa! – Monkey Supersonic Dec 3 '18 at 9:46
  • According to the doc, that is supposed to be supported. But it seems like this tool only returns a pretty formatted string that looks like your typical hex editor. You can't do anything with the 3 columns returned (ignoring metadata). Interested if someone sees it differently and has an example converting from hex back to binary. – TamusJRoyce Apr 20 '19 at 20:54
1

WinHex is the best for you to kick off stupid DOS command.

  1. Open Hex file
  2. Edit>>Converter File
  3. In the dialog box, Select Intel Hex to Binary
  4. Hit OK button.
  5. Round up file Size? Click No.
  6. SAVE File as Bin.
| improve this answer | |
0

If you are nuts, you could try processing the characters via input and then outputting the values 8 bits at a time using a programming language

| improve this answer | |
0

Use this hex to bin converted: (works in browser, no software install necessary)

http://matrixstorm.com/avr/hextobin/ihexconverter.html

| improve this answer | |
-2

You can use the free Mcumall GQ4X programmer software without the programmer. Select the device and load the hex file. Save as a bin file and that is it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.