Hex / Decimal / Binary Converter
Convert between hexadecimal, decimal, and binary number formats instantly.
Formula
Examples
- 0x1C9C380 in decimal
- = 30,000,000
- 18 in hexadecimal = 0x12
- 255 decimal = 0xFF hexadecimal = 11111111 binary
Key Concepts
Why Hex in Blockchain?
Blockchain data is encoded in bytes, and hexadecimal is a compact way to represent bytes. Each hex digit represents 4 bits, so 2 hex digits = 1 byte. This makes hex the natural format for addresses, transaction data, and hashes.
0x Prefix
The '0x' prefix indicates a hexadecimal number. 0x1A means 'the following digits are in base 16.' Without the prefix, 1A could be mistaken for a variable name.
Hex Digits
Hexadecimal uses digits 0-9 and letters A-F (case insensitive). A=10, B=11, C=12, D=13, E=14, F=15. Two hex digits can represent values 0-255 (one byte).
Common Hex Values
0xFF = 255 (max byte). 0xFFFF = 65,535 (max uint16). 0xFFFFFFFF = 4,294,967,295 (max uint32). Solidity's uint256 max is 2^256 - 1.
Reading Block Explorers
Etherscan displays many values in hex: block numbers, gas values, calldata. Being able to quickly convert between hex and decimal helps when analyzing transactions.
Binary in Smart Contracts
Bitwise operations in Solidity (AND, OR, XOR, shift) operate on the binary representation. Understanding binary helps debug these operations and optimize gas usage.
Converting Between Number Bases
Hexadecimal (base 16), decimal (base 10), and binary (base 2) are the three number systems used most frequently in blockchain development. Each serves a different purpose.
Decimal is what humans use daily. Hexadecimal is compact and aligns naturally with bytes (2 hex digits = 1 byte). Binary shows the individual bits that CPUs and smart contracts operate on.
When working with smart contracts, you'll encounter hex in ABI-encoded calldata, function selectors (first 4 bytes of keccak256), and raw transaction data. This converter helps you quickly translate between formats.
Frequently Asked Questions
How large a number can this handle?
JavaScript can safely handle integers up to 2^53 - 1 (9,007,199,254,740,991). For larger values like uint256, you'd need a BigInt library. This tool works for most practical blockchain values.
Is hex case-sensitive?
No — 0xAB and 0xab represent the same value. By convention, Ethereum addresses use mixed case as a checksum (EIP-55), but the hex value itself is case-insensitive.
What's the 0b prefix?
Just as 0x indicates hexadecimal, 0b indicates binary. 0b1010 = 10 in decimal. Not all contexts support this prefix, but it's common in programming languages.