A virtual teacher who reveals to you the great secrets of Base64

Base64 to Hex

The “Base64 to Hex” converter is a free tool which is able to convert online Base64 strings to Hex values. The conversion process is quite simple: the converter decodes the Base64 into the original data, then encodes it to Hex value and gives you the final result almost instantly. If you are looking for the reverse process, check Hex to Base64.


How to convert Base64 to Hex

  1. Type or paste your Base64 value into the “Base64” field.
  2. Select the desired letter case for the hex value.
  3. Limit the output length if you need to extract a certain number of bytes.
  4. Specify a delimiter to separate hex digits.
  5. Press the “Convert Base64 to Hex” button.
  6. Download or copy the result from the “Hex” field.
Comments (40)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • Frank,
    Hi,

    Can I to have got code of fecode base64 to hex in javascript.

    Thank you
    • hifrankwassup,
      Ok frank here

      function base64ToHex(str) {
        const raw = atob(str);
        let result = '';
        for (let i = 0; i < raw.length; i++) {
          const hex = raw.charCodeAt(i).toString(16);
          result += (hex.length === 2 ? hex : '0' + hex);
        }
        return result.toUpperCase();
      }

      console.log(base64ToHex("oAAABTUAAg=="));


      found it on stackoverflow
      • Martin,
        Hi Frank

        Thanks for the code. I would like to implement this in a google sheet. We are forwarding data in hex format that is base64 encoded from the Things Networks to Pipedream and then into google sheets. How would I add your code to the script editor in google sheets to decode our data?

        Any help would be much appreciated.

        Thanks!
        • WebMaster,
          Hello Martin,

          To use the base64ToHex function in Google Sheets, you can create a custom function by following these steps:

          Open your Google Sheets document and go to Tools > Script editor.
          In the Script Editor, create a new function called base64ToHex and paste the code you provided:
          python
          Copy code

          function base64ToHex(str) {
            const raw = atob(str);
            let result = '';
            for (let i = 0; i < raw.length; i++) {
              const hex = raw.charCodeAt(i).toString(16);
              result += (hex.length === 2 ? hex : '0' + hex);
            }
            return result.toUpperCase();
          }


          Save the script and close the Script Editor.
          In your Google Sheets document, select the cell where you want to display the hex value of a base64 string.
          In the formula bar, type =base64ToHex("oAAABTUAAg==") and press Enter.
          This should display the hex value of the base64 string "oAAABTUAAg==" in the selected cell. You can replace this value with a reference to a cell that contains a base64 string to decode it to hex format.

          I hope this helps! Let me know if you have any further questions.
          • Eugene,
            Hello. I tried to launch your code in Google Apps Script. But he does not work, unfortunately. It gives an error - "Referenterror: atob is not defined, basy64tohex @base64tohex.gs: 2" - please tell me how it can be fixed.
  • zepelin16,
    Hi
    i need help with procedure to transform 'Helo' into 'yc2LYupgdVRzUcJYs6+/Lw=='

    Thanks
    • baldur,
      zepelin16, here's some python code

      if input == 'Helo':
        print('yc2LYupgdVRzUcJYs6+/Lw==')
      • test,
        this is awesome
      • steven27,
        Excellent code, greatly solves this problem. Google just offered me a senior dev role after showing them this.
        • hey,
          lol good joke
      • FishlandicFishy,
        Here’s some javascript just in case if you somehow don’t have access to python or something:

        function heloToString(helo) {
          if (helo === ‘helo’) {
            return 'yc2LYupgdVRzUcJYs6+/Lw==';
          } else {
            return helo;
        }

        console.log(heloToString);
        • Simon,
          FishlandicFishy, some errors in your code:

          replace console.log(heloToString);
          to console.log(heloToString("helo"));
          • Abhi,
            FishlandicFishy, after adding your fix to my code my computer just detected signs of life in saturn. This is code of the century.
            • hey,
              lol a even better joke
  • Rakesh,
    Hi,

    Could you please provide me the conversion from base64 string to hex in C? (i.e in hex[0],hex[1], hex[2],...)

    Thank you
  • Tina,
    Hello,

    This page is so helpful, but I have a problem with in base64 to hex.
    Could you provide code from base64 to hex in C,please?

    Thank you!
  • Jack,
    Can anyone share implementation of base64 to Hex in C# ?
  • HernanEspindola,
    Buenas tardes.
    Debo responder un requerimiento, que consiste en convertir un código de Base64 a Hexadecimal, pero codificar dicha conversión en un programa RPG o RPG ILE.
    Sera que ya alguien lo tiene ?
  • smk,
    Hi Can i have code for C#
  • Anil_kumar,
    what is the DCS value of base64 encoding?
  • ZèMì,
    Hello anyone!
    I've a question: Why this hex converter has different result from linux hexdump command?

    here my command:
    echo 'CIAO' | xxd -p

    here the result:
    4349414f0a

    here the convert from this site:
    08800e
    • Administrator,
      Hello! Please note that this tool is a Base64 to Hex converter, not a Hex encoder. That is, in your case this tool decodes CIAO from Base64, then encodes result to Hex.
  • nqhXncMU,
    -1; waitfor delay '0:0:15' --
  • nqhXncMU,
    9LRoVLSj') OR 676=(SELECT 676 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1)) OR 288=(SELECT 288 FROM PG_SLEEP(15))--
  • nqhXncMU,
    1 waitfor delay '0:0:15' --
  • nqhXncMU,
    1
  • gBqsPxAZ,
    1 waitfor delay '0:0:15' --
  • nqhXncMU,
    888cAVGh'; waitfor delay '0:0:15' --
  • ncMUFCMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • ncMUFCMU,
    -1)) OR 387=(SELECT 387 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    Qy8Hc1Vr' OR 872=(SELECT 872 FROM PG_SLEEP(15))--
    • kAshQ__,
      1 I wait for delay 0:0:05 --
  • Berenice,
    The Ultimate Guide To Accident Attorney accident attorney
    no injury [72.13.216.248]
  • Creeper_Sune,
    I can't figure out how to decode UCB4YwbOmgLlYO9_BUwNx7Q to hex.
    For some reason, the program throws an error of "Cannot decode the string. Most likely it’s not Base64 value or it contains invalid data."
    Can anyone help me out?
    • Denis,
      "_" isn't a valid base64 character. "UCB4YwbOmgLlYO9BUwNx7Q" gives 5020786306ce9a02e560ef41530371ed
  • Faramarz_72,
    7gggggggggggggggggggggh0cmFuc2xhdGUuZ29v

    سلام چجوری میتونم اینو رمزگشایی کنم سکرت ۳۲ رقمی بده؟
  • CG3000,
    function base64ToHex(str) {
    const raw = atob(str);
    let result = '';
    for (let i = 0; i < raw.length; i++) {
    const hex = raw.charCodeAt(i).toString(16);
    result += (hex.length === 2 ? hex : '0' + hex);
    }
    return result.toUpperCase();
    }

    console.log(base64ToHex("oAAABTUAAg=="))
  • bob,
    저 는 게나치입니다
  • alqpdbxhzbq50690,
    qwsalsiznxmpzbxscxvnew94061ysxndblaz0456LAQNXYWHDBX
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.