So far I am using this solidity code

pragma solidity 0.4.24;

contract Converter{
    function Converter(){


    function stringToBytes32(string memory source) returns (bytes32 result) {
        bytes memory tempEmptyStringTest = bytes(source);
        if (tempEmptyStringTest.length == 0) {
            return 0x0;

        assembly {
            result := mload(add(source, 32))

Is there a website or online tool to easily convert strings to bytes32?


If you have MetaMask installed, then the following works in the browser console:

> web3.padRight(web3.fromAscii('hello'), 34)
  • This answer is no longer correct. From the official Metamask docs: For historical reasons, MetaMask injected web3@0.20.7 is deprecated. It has known security issues. It is no longer maintained by the web3.js team.
    – YulePale
    May 24 at 13:50

Online GUI here for converting bytes32 to string and the other way: https://blockchangers.github.io/solidity-converter-online/


Cindercloud also had an online converter, as well as some other useful tools for interacting with ethereum and other chains.


Another online GUI:

Convert from a bytes32/hex into a string/number or vice-versa.


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.