Keccak-256 online, the way Solidity computes it
Ethereum uses Keccak-256 everywhere: for function selectors, event topics, storage slots, addresses and signed messages. This keccak256 online calculator gives you the same 32-byte hash Solidity’s keccak256(…) returns, from five kinds of input: plain text, raw hex bytes, values packed with abi.encodePacked, values encoded with abi.encode, and function or event signatures, for which it also gives the 4-byte selector.
It matters which one you pick. keccak256("hello") on text hashes five bytes; keccak256(abi.encode("hello")) hashes 96 bytes of offset, length and padded data, and gives a completely different result. The page shows the exact bytes it hashed in the encode modes, so you can compare them with what your contract does.
Everything runs in your browser with an in-page Keccak implementation shared with this site’s other Ethereum tools; nothing is sent to a server.
How to use the Keccak-256 Hash Generator
- Choose what to hash: Text, Hex, abi.encodePacked, abi.encode or Selector.
- Type or paste the input. For the encode modes write one
type valueper line, such asuint256 42,address 0x…orstring hello. - For selectors, paste one signature per line — names,
indexed,memoryand spaces are removed, anduintbecomesuint256. - Read the hash, the first four bytes and the encoded bytes, and use the copy buttons.
Keccak-256 Hash Generator features
Real Keccak-256
The original Keccak padding used by Ethereum, not NIST SHA3-256.
abi.encodePacked
Tight packing of integers, addresses, bools, bytesN, strings, bytes and arrays.
abi.encode
Standard 32-byte words with offsets and lengths for strings, bytes and dynamic arrays.
Selectors and topics
Canonical signatures, 4-byte function selectors and full event topic hashes, many at once.
Shows the bytes
The exact hex that was hashed, for checking against your contract or tests.
encodePacked vs encode
The Solidity ABI specification defines both encodings. abi.encode writes every static value as one 32-byte word — integers left-padded (negative ones sign-extended), addresses left-padded, bytesN right-padded — and puts strings, bytes and dynamic arrays after the head, each with its length. abi.encodePacked is the “non-standard packed mode”: values shorter than 32 bytes are joined without padding, strings and bytes go in place without a length, and array elements are still padded to 32 bytes.
Worked example: abi.encodePacked(uint8(1), "a") is just the two bytes 0x0161, while abi.encode(uint256(1)) is 31 zero bytes and a 1, whose Keccak-256 is 0xb10e2d52…fa0cf6 — the storage slot hash you see for mappings keyed by 1.
- Packing two dynamic values can collide:
encodePacked("a", "bc")andencodePacked("ab", "c")give the same bytes and the same hash. Use abi.encode when hashing several strings together. - Nested arrays, arrays of strings and structs are not supported in the encode modes here; use the contract ABI decoder’s encoder for full function calls.
Function selectors and event topics
A function selector is the first four bytes of the Keccak-256 hash of the function’s canonical signature: its name and parameter types, with no spaces and no names. transfer(address,uint256) hashes to 0xa9059cbb…, so every ERC-20 transfer call starts with a9059cbb. Events use the full 32-byte hash as topic 0: Transfer(address,address,uint256) is 0xddf252ad…b3ef. Tuples are written as their component types in brackets, so a struct parameter becomes (address,uint256).
To decode a whole transaction from its ABI, use the contract ABI decoder; for MD5, SHA-256 and other general hashes, the hash generator; and to derive an address from a public key, the public key to address converter.
Keccak-256 Hash Generator FAQ
Is keccak256 the same as SHA3-256?
No. Ethereum adopted Keccak before NIST changed the padding for the final SHA-3 standard, so keccak256 and SHA3-256 give different hashes for the same input. Solidity’s old sha3() was an alias for keccak256.
How do I get keccak256 of abi.encodePacked online?
Choose abi.encodePacked and enter one “type value” per line in the same order as in your code, for example address 0x… then uint256 42. The page shows the packed bytes and their hash.
How do I calculate a function selector?
Write the canonical signature — name and types, no spaces, uint as uint256 — and take the first 4 bytes of its Keccak-256. Paste the signature in Selector mode to get it.
Why does my hash not match Solidity?
Usually the input differs: text vs bytes, abi.encode vs abi.encodePacked, uint8 vs uint256, or a hidden newline. Compare the bytes shown here with your contract.
Does it hash a string with or without a trailing newline?
Exactly as typed — a line break you type is part of the input, and none is added.
Is my input sent anywhere?
No. Hashing happens in your browser.