TradePortfolio

Token Decimal Converter

Convert raw on-chain token amounts to human-readable values and back, for any decimal precision.

Formula

Raw to Human Readable
Human Readable to Raw

Examples

Example 1: 1,000,000 USDC (6 decimals)
  • Raw: 1000000000000
  • Decimals: 6
  • Display = 1,000,000,000,000 / 10^6 = 1,000,000 USDC
Raw amount 1000000000000 = 1,000,000 USDC
Example 2: 1.5 ETH in Wei (18 decimals)
  • Display: 1.5 ETH
  • Decimals: 18
  • Raw = 1.5 × 10^18 = 1,500,000,000,000,000,000 Wei
1.5 ETH = 1,500,000,000,000,000,000 Wei
Example 3: 0.01 WBTC (8 decimals)
  • Display: 0.01 WBTC
  • Decimals: 8
  • Raw = 0.01 × 10^8 = 1,000,000
0.01 WBTC = 1,000,000 raw units

Key Concepts

Why Token Decimals?

Blockchains can't handle floating-point numbers natively. Instead, tokens store values as large integers with an implied decimal point. '18 decimals' means the raw integer is divided by 10^18 for display.

Common Decimal Values

ETH/ERC-20 default: 18 decimals. USDC/USDT: 6 decimals. WBTC: 8 decimals. Some NFT contracts use 0 decimals (whole numbers only).

Reading On-Chain Data

When a block explorer shows a raw transfer value of 1500000000000000000, that's 1.5 tokens with 18 decimals — not 1.5 quadrillion tokens.

Precision Matters

Using too few decimals truncates values. Solidity's uint256 can store up to ~10^77, which gives plenty of headroom for 18-decimal tokens. But if you divide before multiplying in Solidity, you lose precision.

Token Approval Amounts

The famous 'infinite approval' uses the max uint256 value. In raw form, that's 115792089237316195423570985008687907853269984665640564039457584007913129639935.

Cross-Token Conversions

When swapping between tokens with different decimals (e.g., WBTC with 8 and ETH with 18), you must account for the decimal difference. A raw amount in one token means something very different in another.

Understanding Token Decimals

Every ERC-20 token has a 'decimals' property that defines how many places to shift the decimal point when converting between the raw on-chain integer and the human-readable display amount.

This is critical for smart contract development, API integration, and reading raw blockchain data. Sending the wrong raw amount (forgetting to multiply by 10^decimals) is a common and costly mistake.

This converter handles both directions: paste a raw on-chain value to see the display amount, or enter a display amount to get the raw value you'd need for a contract call.

Frequently Asked Questions

How do I find a token's decimals?

Check the token contract on a block explorer (Etherscan → Read Contract → decimals()). Most ERC-20 tokens use 18, but stablecoins often use 6 and WBTC uses 8.

Why do some amounts look huge on-chain?

A transfer of 1 USDC looks like 1000000 on-chain because USDC has 6 decimals. 1 ETH looks like 1000000000000000000 with 18 decimals. The converter handles this translation.

Can I use this for non-EVM chains?

Yes — any token with fixed-point decimal representation works. Solana's SPL tokens typically use 6-9 decimals. Just enter the correct decimal count.