Random binary generator — random bits, octal, decimal or hex strings

Choose a base and a length, and the tool writes random digit strings, such as 1100 0101 1010 0011 in binary, and tells you how many bits of randomness each one holds.

Live demo · real result from this tool
0 = no spaces

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the random binary generator

  1. Choose the Base: Binary, Octal, Decimal or Hexadecimal.
  2. Set Digits, the length of each string, from 1 to 4,096.
  3. Set Group every to put a space after that many digits. Use 0 for no spaces.
  4. Enter How many strings you need (1 to 200), and tick No leading zero if the first digit must not be 0.
  5. Press Generate and use Copy all to take the whole list.

What it does and when to use it

Use it to make test data: random bit patterns for a digital-logic exercise, hex strings that look like IDs or keys, octal values for permission puzzles, or long digit strings for a parser test. Teachers can generate a set of binary numbers for students to convert by hand and then check them with the binary calculator.

For ready-made identifiers in a standard format, use the UUID generator. To turn binary back into readable text, try binary to text. For numbers in a range rather than fixed-length strings, use the random number generator.

How it works

Each digit is drawn on its own from the digits allowed in the base: 0–1, 0–7, 0–9 or 0–9 and a–f. The draw uses crypto.getRandomValues with rejection sampling, so every digit is equally likely and there is no bias towards small values. Grouping only adds spaces for reading; it does not change the digits.

The bits figure is the length times log₂ of the base. It tells you how many guesses an attacker would need in the worst case: 2 to the power of the bits.

Worked examples

16 binary digits in groups of 4 (the default). One run gave 1100 0001 0101 0011. Each string holds 16 bits of randomness.

8 hex digits, no grouping. One run gave 9d6d694c and 7859ae6d, each worth 32 bits.

6 decimal digits. Each string is worth 6 × 3.32 ≈ 19.9 bits, which matches the one-in-a-million chance of guessing a 6-digit code.

Limits and tips

  • Strings are capped at 4,096 digits and 200 per press.
  • Values with a leading zero, such as 0042, are valid strings but may lose the zero when pasted into a spreadsheet; format the column as text first.
  • Strings are made on your device and are not stored or sent anywhere.

Frequently asked questions

How is "Randomness per string" worked out?
It is the number of digits times log₂ of the base. A binary digit holds 1 bit, an octal digit 3, a hex digit 4 and a decimal digit about 3.32. So 32 hex digits give 128 bits.
Are these strings safe to use as secret tokens?
The digits come from crypto.getRandomValues, the browser's cryptographic source, so they are unpredictable. Still, treat any secret you generate on a web page with care. For passwords, the strong password generator is the better fit.
What does No leading zero do?
If the first digit comes out as 0, it is replaced with a random non-zero digit, so a decimal string of 6 digits is always a real 6-digit number. This removes a little randomness, and the bits figure accounts for it, because the first digit has one choice fewer, so 8 binary digits give 7 bits.
Are hex letters upper or lower case?
Lower case, a to f. Change the case afterwards with any text tool if your system needs capitals.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close