Ethereum denominations in one place
Ethereum amounts are stored onchain as integers of wei, the smallest unit. People read them as gwei for gas prices and ether for balances. This converter turns any of those into all the others at once.
Key facts
- 1 ether = 10^18 wei = 10^9 gwei.
- Exact BigInt math, so values above 2^53 keep every digit.
- Runs in your browser. Nothing is sent to a server.
- Covers wei, kwei, mwei, gwei, szabo, finney, and ether.
Unit reference
| Unit | Also called | Wei |
|---|---|---|
| Wei | 1 | |
| Kwei | babbage | 10^3 |
| Mwei | lovelace | 10^6 |
| Gwei | shannon | 10^9 |
| Szabo | microether | 10^12 |
| Finney | milliether | 10^15 |
| Ether | 10^18 |
Where each unit shows up
- Gwei is the unit of gas prices and priority fees. A base fee of 25 gwei is 25,000,000,000 wei per unit of gas.
- Ether is the unit of balances and transfer amounts in wallets and explorers.
- Wei is what contracts, RPC responses, and
msg.valueactually carry.
Many ERC-20 tokens use 18 decimals like ether, but not all do. USDC uses 6. To convert a token amount, use the token’s own decimals() value rather than assuming 18. The ERC-20 Token Inspector reads it for you.
Converting in code
import { formatUnits, parseUnits } from "viem";
parseUnits("1.5", 9); // 1500000000n (1.5 gwei in wei)formatUnits(123456789012345678n, 18); // "0.123456789012345678"For onchain reads, you can skip this step. An evmquery expression can scale a raw value on the server with formatUnits:
string(formatUnits(token.balanceOf(owner), token.decimals()))The response comes back already formatted, so your code never handles a raw wei value. See the Token Allowance Checker for a worked example.
FAQ
How many wei are in one ether?
One ether is 1,000,000,000,000,000,000 wei, which is 10^18. One gwei is 10^9 wei, so one ether is also one billion gwei.
How do I convert gwei to ether?
Divide by 10^9. For example, 30 gwei is 0.00000003 ether. Enter 30 with the unit set to gwei and the converter shows the ether value directly.
Why use BigInt instead of normal numbers?
Wei amounts easily exceed 2^53, the largest integer a JavaScript number stores exactly. Floating point math silently rounds above that. This converter parses the amount into a BigInt number of wei and formats from there, so every digit is exact.
Does the converter send my input anywhere?
No. The conversion runs entirely in your browser and makes no network request.
Why is more precision than the unit allows rejected?
Wei is the smallest unit and cannot be divided. An input like 1.5 wei has no valid onchain value, so the converter reports an error instead of rounding it.
How do I get formatted values from onchain reads?
Use formatUnits inside the evmquery expression. A raw uint256 balance returned by a contract can be scaled by the token’s decimals on the server, so the response is already human readable.
Related
- Keccak256 and Function Selector: hash text and derive 4-byte selectors
- ERC-20 Token Inspector: read a token’s decimals and supply, formatted
- Token Allowance Checker: an allowance read with decimal formatting applied