Random Binary Number Generator
Generate a random string of binary bits of any length and instantly read its decimal and hexadecimal value. Useful for coding practice, teaching number systems, seeds and test data — all crypto-strong and private.
How to use the Random Binary Generator
Choose 1 to 64 bits — 8 bits is one byte.
Each bit is an independent fair 0 or 1.
See the decimal and hexadecimal value of the binary string.
Grab the binary string for your code, lesson or test fixture.
About this tool
Binary is the language computers actually use: every value is built from bits, each a 0 or a 1. This random binary generator produces a fresh string of fair, independent bits and converts it for you into decimal (base 10) and hexadecimal (base 16), the compact notation programmers use to read bytes at a glance.
Each bit is drawn from the browser’s crypto.getRandomValues generator, so the string is unbiased. An 8-bit number ranges from 0 to 255, 16 bits reaches 65,535, and the tool supports up to 64 bits. Values above 53 bits are shown using big-integer-safe conversion so the decimal stays exact.
Frequently asked questions
How many bits should I pick?
It depends on your need: 8 bits (one byte) covers 0–255, 16 bits covers 0–65,535, and 32 bits is a common machine word. The tool supports 1 to 64 bits.
Are the bits unbiased?
Yes. Each bit is an independent draw with a 50% chance of 0 or 1 using crypto-strong randomness, so all bit patterns of a given length are equally likely.
How is the decimal value calculated?
Each bit contributes a power of two: the rightmost bit is 1, then 2, 4, 8 and so on. The tool sums these for the decimal value and groups bits into hex digits for the hexadecimal value.
Is it accurate for large bit counts?
Yes. For lengths beyond 53 bits the tool uses JavaScript BigInt so the decimal and hex conversions remain exact rather than rounding.