What is Bech32?
Bech32 is a way to write binary data as short, safe text. It was defined for Bitcoin SegWit addresses in BIP-173. A Bech32 string has three parts: a prefix called the human-readable part (for example bc for Bitcoin mainnet), the digit 1 as a separator, and the data written in a 32-letter alphabet. The last six characters are a checksum. The alphabet leaves out 1, b, i and o, because they look alike. A string can be all lower case or all upper case, never mixed.
The checksum is the reason people use it. It is a BCH code that detects any error of up to four characters, and it is far more reliable than the old Base58Check checksum. QR codes also store upper-case Bech32 compactly.
BIP-350 introduced Bech32m. A bug-like property of the original checksum made some mistakes in Taproot addresses harder to catch, so the new variant changes one constant in the checksum. The two variants look the same, which is why a tool has to try both. Bitcoin SegWit version 0 addresses (starting with bc1q) use Bech32. Versions 1 to 16, including Taproot (bc1p), use Bech32m.
This page works in two directions. Decode takes a string, finds the variant, checks the checksum, shows the prefix and the payload as hexadecimal bytes and as 5-bit values, and recognizes SegWit addresses: witness version, program, and whether the variant and the length are allowed. Encode takes a prefix and a hex payload and builds the string, or builds a SegWit address from a version and a program. The tool checks the format and the checksum only. It cannot tell whether the address exists or has funds. For turning a seed phrase into addresses, see the wallet address batch and the BIP39 generator. The official text is BIP-173: github.com/bitcoin/bips/blob/master/bip-0173.mediawiki.
How to decode or encode Bech32
- In What to do, choose Decode or Encode.
- To decode, paste the text into Bech32 or Bech32m string:. Upper or lower case both work.
- Read the Result: Variant:, Checksum:, Prefix (human-readable part): and Payload as bytes (hexadecimal):. If the data is not a whole number of bytes you see Payload as 5-bit values: instead.
- For a SegWit address, the page also shows the witness version and Witness program (hexadecimal):, and warns if the variant or the length is wrong for that version.
- To encode, fill in the prefix and Payload (hexadecimal bytes):, pick the variant, and click Copy string. For an address, choose SegWit address and set Witness version: and Witness program (hexadecimal):.
- Use Use this in the encoder to move a decoded result into the encoder and change it.
- Turn on Allow long strings only when you work with something other than a standard address. BIP-173 limits a string to 90 characters.
Examples
A SegWit version 0 address
Decode this address from BIP-173:
bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4The prefix is bc, the variant is Bech32, the witness version is 0 and the program is 20 bytes:
751e76e8199196d454941c45d1b3a323f1433bd6Encoding that program with version 0 and prefix bc gives the same address back. Upper case BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4 decodes the same way.
A Taproot address
This address from BIP-350 is witness version 1 and uses Bech32m:
bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0Its program is 32 bytes:
79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798If the same program were written with the Bech32 checksum, the page would warn that wallets reject it.
Empty payloads from the specs
With an empty payload, prefix a gives a12uel5l in Bech32 and a1lqfn3a in Bech32m. These are the shortest valid vectors in the standards, and they show the variants differ only in the six-character checksum. The string split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w is another official vector, with prefix split.
Common errors and how to fix them
- "The string mixes upper and lower case. Bech32 must be all one case.": change the whole string to lower or upper case.
- "There is no prefix: Bech32 is a prefix, the digit 1, and the data.": the string has no
1separator, or it is at the very start. Check that you copied the whole value. - "The character "{char}" (position {position}) is not in the Bech32 alphabet. Bech32 has no 1, b, i or o in the data.": a typing mistake. Look for
0andO, orland1. - "The data part is too short: it needs at least the 6 characters of the checksum.": the string was cut.
- "The checksum is wrong for both Bech32 and Bech32m: a character was changed, missing or added.": the string is damaged. Compare it with the source.
- "The string has {length} characters; the limit is {limit}. Turn on "Allow long strings" if it is meant to be longer.": turn on the option if the string is not a Bitcoin address.
- "Character {position} of the prefix is not allowed (only printable ASCII).": fix the prefix.
- "The payload is not hexadecimal: use 0-9 and a-f, in pairs.": remove spaces and
0x, and give an even number of digits. - "The program has {length} bytes; SegWit takes 2 to 40 (20 or 32 for version 0).": check the length of the program.
Frequently asked questions
What is the difference between Bech32 and Bech32m?
Only the final constant of the checksum. Bech32m fixes a weakness of the original that affected strings ending in p, and it is required for witness version 1 and above. Version 0 stays with Bech32.
Does a valid checksum mean the address is safe to send money to?
No. It means the text has no typing error. It does not mean the address belongs to the person you think, or that it is the right network. Always compare the prefix and send a small test first.
Why can't Bech32 addresses use mixed case?
Mixed case would make the address hard to copy by voice and in QR codes, and it opens a door for confusion. The standard says all lower or all upper, and the decoder rejects anything else.
Is anything sent to a server?
No. Everything runs in your browser. Still, addresses are public, so there is no secret here. If you need the hex bytes for other work, see hex and text.