Is there an app/script out there that can convert a series of bytes from hex to dec (if not, is there an easy way to achieve this in the command prompt in a few lines)?

03 01 9d f0 b4 05 01 67 40 20 00 6b ad

There are tons of online converters, like this one: http://home2.paulschou.net/tools/xlate/

  • -1 for just posting a link. This is a place for collecting knowledge, what happens if the link dies?
    – Nifle
    Jul 7 '11 at 23:47
  • 1
    @Nifle Use one of the thousands of others out there? The OP didn't ask for a lesson on Hexadecimal mathematics, just a one-off conversion. Jul 8 '11 at 0:06
  • @Amazed: I think Nifle meant ones similar to the link you've included, but these thousands of others would be suffice (didn't know the keywords to search for them properly originally)
    – stanigator
    Jul 8 '11 at 7:41

.js script for cscript:

num = [];
for (i = 0; i < WScript.Arguments.Length; i++) {
    arg = WScript.Arguments(i);
    num.push(parseInt(arg, 16));
WScript.Echo(num.join(" "));

Batch script for cmd.exe:

@echo off & setlocal
set /a out=0x%1
    if "%~1"=="" goto :end
    set /a num=0x%1
    set out=%out% %num%
    goto :loop

If all you want is a string of hex to a string of decimal, then this tiny perl program will do it:

while(<>){s/(.\s*.)\s*/hex($1).' '/eg;print;}


68edcdec4e2c8eae8d2c8e2dedcd6e04d2042fedae52ceac04 ccedaecd8c042ccd8c046cedad0e8dac8eac8c048e0dac044a a82889046c0d2c8d8daccdecacc5042bedae4e04ee2dcd046c

./hex2dec.pl < input.hex

It's forgiving about white space in the source and only looks for consecutive pairs of hex digits.

Just modify with sprintf, push, split etc to control output format

If you install perl on windows, then this will work on the command line:

perl -e "while(<>){s/(.\s*.)\s*/hex($1).' '/eg;print;}" < input.hex

Perl is amazing. Noone should be without it!

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.