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?

  • I have attempted the similar once. I succeeded by turning the source into a javascript-escaped string with a regex and unescaping.
    – Jan Dvorak
    Commented Nov 1, 2012 at 17:22
  • From @fadelix: you can check this articles: indogeeks.com/how-to-convert-any-files-to-hex-with-script
    – fixer1234
    Commented Sep 21, 2015 at 3:49
  • @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
    Commented Nov 17, 2015 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
    Commented Nov 6, 2018 at 9:14

9 Answers 9


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.

  • 1
    I have downloaded this package but I do not see the xxd.exe anywhere in the package..
    – Kevin
    Commented Nov 1, 2012 at 17:40
  • My apologies. I swear that's where I fetched it from long ago.
    – Greg Jandl
    Commented Nov 1, 2012 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
    Commented Aug 30, 2013 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
    Commented Nov 17, 2015 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
    Commented Nov 18, 2015 at 0:03

VIM 7.x contains xxd for Windows


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


xxd is available https://sourceforge.net/projects/xxd-for-windows/

xxd v1.11, 8 jun 2013 by Juergen Weigert et al. (Win32)

C:\Users\User>C:\xxd1p11\xxd-1.11_win32\xxd.exe -v
xxd v1.11, 8 jun 2013 by Juergen Weigert et al. (Win32)

  • 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
    Commented Nov 12, 2015 at 12:57
  • Chrome blocks xxd.exe from ge.tt/5jfutZq/v/0 as malware.
    – rossmcm
    Commented Nov 17, 2015 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
    Commented Nov 18, 2015 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
    Commented Nov 18, 2015 at 6:06
  • 1
    xxd is also archive.org/details/hexviewer_Xxd_x86
    – barlop
    Commented Nov 6, 2018 at 9:51

To convert a hex string into a binary file, this works in PowerShell Core 7.2.1:

$hex_string = '48656C6C6F2C20576F726C6421'
$hex_string_spaced = $hex_string -replace '..', '0x$& '
$byte_array = [byte[]] -split $hex_string_spaced
Set-Content -Path 'out.bin' -Value $byte_array -AsByteStream

That last line won't work in PowerShell 5.1, but you can do this instead:

Set-Content -Path 'out.bin' -Value $byte_array -Encoding Byte

PowerShell comes pre-installed with Windows.

  • 1
    Works in PowerShell 4 with -Encoding Byte
    – Ivan Chau
    Commented Jan 15 at 6:42

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........
  • This question is about converting a hex dump into a binary, not vice versa! Commented Dec 3, 2018 at 9:46
  • 2
    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. Commented Apr 20, 2019 at 20:54

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.

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

  • 1
    This is a very old post, but it is really a comment rather than an answer.
    – fixer1234
    Commented Nov 15, 2016 at 19:26
  • Thanks. I am nuts. Your answer inspired mine.
    – durette
    Commented Jan 21, 2022 at 18:37

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



I wrote this in C and tested it in Cygwin.


gcc stdin_hex_to_stdout_bin.c -o stdin_hex_to_stdout_bin
echo '48656C6C6F2C20576F726C6421' | ./stdin_hex_to_stdout_bin
cat some_hex_text_file.txt | ./stdin_hex_to_stdout_bin


#include <stdio.h>
#include <stdbool.h>

int input_char_to_mask(int input_char);

int main() {
   int inputc;
   int outputc;
   int outputmask;
   int mask;
   bool high = false;
   do {
      inputc = getc(stdin);
      outputmask = input_char_to_mask(inputc);
      if (outputmask != 0xFF) {
         if (!high) {
            outputc = outputmask * 16;
         } else {
            outputc = outputc | outputmask;
            putc(outputc, stdout);
         high = !high;
   } while (inputc != EOF);
   return 0;

int input_char_to_mask(int input_char) {
   switch (input_char) {
      case '0': return 0x00;
      case '1': return 0x01;
      case '2': return 0x02;
      case '3': return 0x03;
      case '4': return 0x04;
      case '5': return 0x05;
      case '6': return 0x06;
      case '7': return 0x07;
      case '8': return 0x08;
      case '9': return 0x09;
      case 'A': return 0x0A;
      case 'B': return 0x0B;
      case 'C': return 0x0C;
      case 'D': return 0x0D;
      case 'E': return 0x0E;
      case 'F': return 0x0F;
      case 'a': return 0x0A;
      case 'b': return 0x0B;
      case 'c': return 0x0C;
      case 'd': return 0x0D;
      case 'e': return 0x0E;
      case 'f': return 0x0F;
      default : return 0xFF;

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .