Why decimals vary at all
ERC-20 contracts store amounts as plain integers — there’s no native decimal type in the EVM. A token’s decimals() value just tells wallets and explorers where to mentally place the decimal point when displaying an amount. ETH-like 18 decimals is common but not universal: USDC and USDT use 6, WBTC uses 8, and some tokens deliberately use 0.
Where this trips people up
Reading a raw event log or calldata argument for an unfamiliar token and assuming 18 decimals (because that’s what most examples use) can be off by orders of magnitude — a 6-decimal token’s raw amount of 5000000 is 5 tokens, not 0.000000000005. Getting the decimals value right first is what makes the rest of the conversion trustworthy.
How this tool works
Conversion uses viem’s formatUnits/parseUnits with whatever decimals value you set, backed by native BigInt arithmetic — exact for any token, any amount size, entirely in your browser.