Random Binary Generator
Generate a random binary (base-2) string of any length, made up of 0s and 1s.
Recommended Settings
Pro Tips
- •Each bit is generated independently, so both 0 and 1 are equally likely at every position
- •Binary is base-2 - every 8 bits (a byte) can represent values from 0 to 255
- •Use a longer length to simulate byte-aligned data, like 8, 16, 32, or 64 bits
- •This uses the Web Crypto API for randomness, the same secure source used for the site's password generators
Most Popular
Most users generate 8 or 16-bit values for byte-aligned examples and coding exercises
When to Use This Tool
Generate example binary values for teaching number systems or bitwise operations.
Create random binary strings for testing parsers or bit-manipulation code.
Get a random binary value to practice AND, OR, XOR, and shift operations by hand.
Generate example bit patterns for demonstrating flags or bitmasks.
How It Works
Generate the requested number of bits, choosing 0 or 1 independently and uniformly at random for each position
Use the Web Crypto API as the source of randomness rather than Math.random()
Display the resulting binary string and update it live as you adjust the length
100% Private
Files never leave your device. All processing happens locally in your browser.
Lightning Fast
Powered by Web Crypto API (crypto.getRandomValues) for optimal performance on modern browsers.
Open Source
Built with verified, open-source libraries. Fully transparent.
Frequently Asked Questions
What length can I generate?
Between 4 and 128 bits using the slider.
Is each bit equally likely to be 0 or 1?
Yes, each bit is generated independently using a cryptographically secure random source, so 0 and 1 are equally probable at every position.
Is my data sent to a server?
No. The binary string is generated entirely in your browser.
Can I convert this to hexadecimal or decimal?
This tool only generates binary. Use a dedicated base conversion tool to convert the result to another number system.
Why would I need random binary data?
It's commonly used for teaching number systems, testing bit-manipulation code, or generating example flag and bitmask values.