Random Binary Generator

Generate random binary numbers of any bit length.

0 binary numbers

Random Binary Number Generator

Generate random binary numbers made of 0s and 1s with exactly the number of bits you choose. Create single bytes, 16-bit words, 32-bit registers or long bit strings of up to 4,096 digits, grouped into nibbles or bytes for readability and optionally prefixed with 0b as used in Python, JavaScript, C++ and Rust.

What you can set

  • Bits per number – the length of each binary value.
  • How many – generate a single value or thousands at once.
  • Group digits – insert a space every 4, 8 or 16 bits: 1011 0010.
  • Start with 1 – no leading zeros, so the value really uses all bits.
  • 0b prefix – output literals ready to paste into source code.

Why generate random binary?

Computer science students practise converting binary to decimal and hexadecimal, adding binary numbers and applying AND, OR and XOR operations. Random values make sure every exercise is new. Engineers use random bit patterns as test vectors for digital circuits, checksums, serial protocols and bit manipulation functions, where hand-written values tend to miss edge cases.

Randomness

Each bit is an independent fair coin flip from crypto.getRandomValues. Because every bit pattern is equally probable, random binary strings are also handy for demonstrating entropy: an n-bit random value carries exactly n bits of entropy.

Next steps

Convert your results with the Binary to Decimal converter or try bitwise operations on them in the Bitwise Calculator. If you prefer byte-oriented output, the Random Byte Generator produces bytes in hex, decimal, binary or base64.

Frequently Asked Questions

Yes. Each bit is drawn independently with a 50% chance of 0 and 50% of 1 from the browser's secure random source, so an n-bit number is uniform over all 2^n values.

It forces the most significant bit to 1, so an 8-bit result always lies between 10000000 (128) and 11111111 (255) and never has leading zeros. This is useful when the length of the number must equal the bit count.

Up to 4,096 bits per number and 10,000 numbers per click. Grouping by 4, 8 or 16 digits makes long values much easier to read.