Example value: 0x2c1c986f1c48000

from: here

Expected value back: 0.19866144 Eth

3 Answers 3


Ether fixed point numbers are higher precision than javascript floats, so you will need to use a library that supports those bigger values.

In Web3 you can simply do:

let bigNumber = web3.toBigNumber('0xFFFFFF')
  • I come up with: parseInt(0x2c1c986f1c48000, 16) / Math.pow(10, 18) link
    – Sunny
    Commented Oct 20, 2017 at 6:48

Try this with ethers.js utils:

ethers.utils.formatEther('1000000000000000000') // return 1.0

You can use the BigNumber library:

var value_wei = "0x2c1c986f1c48000";
var value_ether = new BigNumber(value_wei).dividedBy(new BigNumber("1000000000000000000");

To explain: Ethereum works with units of wei. 1 ether is 1e18 wei, so you have to deal numbers that are too large to be handled by javascript. The BigNumber library accepts representation of numbers a strings, so you can go around this problem.

Note that all functions in web3.js always return values in wei as a BigNumber object, so the return of web3.eth.getBalance(...) can be directly used with the lines above, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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