Thousands of tools! Check out Online Tools – I have now added thousands of tools.

I often have to generate random bits so I created this simple online utility that does it for me. It lets you generate as many random bits or bit groups as you need. It works in the browser and is powered by alien technology from the future.

Random Bit Generator Options

Bit Length and Count
Bit Separator
Bit Format
Choose binary prefix or postfix.
Show a base-10 number next to each binary value.

Random Bit Generator Examples (click to try!)

100 Random Bit Groups
This example generates a random sequence of groups of bits with 1 to 4 bits in each group. The group-length option contains the value "1-4", which is interpreted as "1 to 4 bits". The total number of bit groups is 100 and they are all displayed in the output text area separated by a space character.
0 011 1101 0110 1 0 1011 100 00 010 01 0100 0111 00 010 0 1000 1 0100 110 00 0 0 10 0100 001 011 1 11 0 1 11 0011 011 11 001 1000 01 11 1111 11 111 1000 0 0 01 1100 10 1 001 001 1 1001 000 1 0 0001 0011 1 1 11 1101 1 111 1 1 110 11 0011 10 00 00 000 00 1110 0101 11 101 0110 0 00 00 0 110 0001 011 0 111 110 0 00 1000 10 1100 01 111 101 1 111 1000
Number of bits in one group.
How many bit groups to generate?
Separate individual bits with this character.
Separate bit groups with this character.
Pad Bits with Zero
Specify padding length.
Print Decimal Value
Ten Random Bytes
In this example, we set the bit group length to 8, which is a full byte. We generate ten eight-bit values and print them in a column by entering the character "\n" as the group separator. We also append the binary prefix "0b" to bits and print the corresponding decimal value in parentheses.
0b10101110 (174)
0b00010110 (22)
0b00110000 (48)
0b10110100 (180)
0b01110101 (117)
0b01011111 (95)
0b00010111 (23)
0b10100000 (160)
0b00111110 (62)
0b00110110 (54)
Number of bits in one group.
How many bit groups to generate?
Separate individual bits with this character.
Separate bit groups with this character.
Pad Bits with Zero
Specify padding length.
Print Decimal Value
Pad Bits with Ones
In this example, we enter the value "1, 2, 4-6" in the bit length option, which makes the program generate one-bit, two-bit, four-bit, five-bit, and six-bit values. We pad the binary numbers with ones so that all values have the same length equal to 8. We put a dot character between random bits and a comma character between groups of bits. We also print the integer value of binary value and add a base-2 subscript "₂".
1.1.1.0.0.1.0.1₂ (229), 1.1.1.1.1.0.1.1₂ (251), 1.1.0.1.1.1.1.1₂ (223), 1.1.1.1.1.1.1.1₂ (255), 1.1.1.1.1.1.1.1₂ (255), 1.1.1.1.1.1.0.1₂ (253), 1.1.1.1.1.1.1.0₂ (254), 1.1.0.0.0.1.0.0₂ (196), 1.1.1.0.0.1.0.1₂ (229), 1.1.1.1.0.0.0.0₂ (240), 1.1.1.0.1.1.1.0₂ (238), 1.1.1.0.0.0.0.0₂ (224), 1.1.1.1.0.1.0.0₂ (244), 1.1.1.1.1.1.0.1₂ (253), 1.1.0.1.0.1.0.1₂ (213), 1.1.1.1.0.0.1.0₂ (242), 1.1.1.1.1.0.1.1₂ (251), 1.1.1.1.1.1.0.0₂ (252), 1.1.1.1.1.1.1.0₂ (254), 1.1.1.1.1.1.0.0₂ (252)
Number of bits in one group.
How many bit groups to generate?
Separate individual bits with this character.
Separate bit groups with this character.
Pad Bits with One
Specify padding length.
Print Decimal Value

How Does This Random Bit Generator Work?

This random bit generator works entirely in your browser and is written in JavaScript. To generate random bits, it runs two nested for loops. The first loop runs count times. This variable can be set in the options and it determines how many individual bits or bit groups will appear in the output. Generating individual bits is the same as generating bit groups of length one. In every iteration, it creates an empty array groupBits = [] that will store the randomly generated bits. If the group length is one, then single bits will be generated. Otherwise, groups of multiple bits will be generated. The groupLength variable controls how many bits will appear in a single bit group. This variable takes a comma-separated list of lengths. For example, the value 2, 4, 7-8 will generate bit groups with two, four, or seven, or eight bits. The contents of the groupLength variable is parsed and stored in the groupLengths array. In the example with the value 2, 4, 7-8, the groupLengths array becomes [2, 4, 7, 8]. To select a group length from several, the program generates a random array index using the formula Math.floor(Math.random() * groupLengths.length) and puts the element with this index into the variable curBitLen. This variable determines how many bits will be randomly generated. At this point, the inner loop is set up and runs curBitLen times. It generates random bits using the formula bit = Math.floor(Math.random() * 2). When a bit is generated, it's pushed to the groupBits array. After filling this array with curBitLen bits, the program converts them into a string by calling the groupBits.join(bitSeparator) method. Then, it adds the optional padding, prefix, and decimal value to this string, and pushes the formatted group of bits to the bitsOut array, and repeats the outer loop again. After generating count bit groups, the program calls bitsOut.join(groupSeparator) function that creates the final string of all bit groups and it's then displayed on the screen.

Created by Browserling

This random bit generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our web developer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.