Convert ERC-20 amount

Convert an ERC-20 display amount to base units or turn a raw balance back into decimal notation.

freeworks offlinenothing uploaded
ToolERC-20 Amount Converter
Input
Output

How it works

A display amount is multiplied by 10^decimals and represented as an integer; the reverse direction inserts the decimal point that many places from the right. BigInt-backed arithmetic preserves exact token units instead of rounding through binary floating point.

  • Eighteen decimals is a common starting convention, while the contract metadata remains authoritative.
  • No symbol is assumed, so the same arithmetic works for every ERC-20 token.

Worked example

12.5 USDC to raw units
USDC uses 6 decimals, not the usual 18
Input
											Value: 12.5
Decimals: 6
Direction: humanToRaw
										
Output
												Human amount: 12.5
Raw amount: 12500000
											

When to use this

Wallets format balanceOf values, approve forms prepare integer calldata, and indexers render Transfer events.

Edge cases

  • More fractional digits than the token supports cannot be represented and are rejected rather than rounded.
  • A raw balance containing a decimal point is invalid because on-chain balances are integers.
  • Large supplies stay exact as strings beyond JavaScript Number’s safe integer range.

References