Skip to content
DevToolKit

Random Binary File Generator

Generate cryptographically random binary files of any size using the Web Crypto API. Includes entropy visualization, byte distribution histogram, and Shannon entropy scoring.

Quick:
Cryptographically Secure Random Data

This tool uses the Web Crypto API (crypto.getRandomValues()) to generate cryptographically secure pseudorandom numbers. The output is generated entirely in your browser and draws from your operating system's entropy pool. Data is produced in 64 KB chunks for optimal performance.

Was this tool helpful?

How to Use

Generate cryptographically random binary files of any size directly in your browser. The tool uses the Web Crypto API's crypto.getRandomValues() function and provides real-time entropy analysis to verify output quality.

Step-by-step guide

  1. Set the file size — enter a number and select a unit (Bytes, KB, or MB). Use the quick-size buttons to jump to common sizes like 1 KB, 10 KB, 100 KB, 1 MB, or 10 MB.
  2. Click Generate — the tool begins producing random data in 64 KB chunks. A progress bar tracks generation for larger files.
  3. Review the statistics — after generation, four metrics appear: file size, generation time, Shannon entropy (bits per byte), and a randomness quality percentage. Entropy near 8.0 bits/byte confirms uniform randomness.
  4. Inspect the histogram — the byte distribution chart shows how often each possible byte value (0x00 through 0xFF) occurs. For cryptographically random data, the histogram should appear nearly flat. A dashed line marks the expected uniform frequency.
  5. Download the file — click Download to save the binary file. You can customize the filename before downloading.
  6. Reset and regenerate — click Reset to clear the results and configure a new file size.

Understanding the histogram colors

Each bar in the histogram is color-coded based on its deviation from the expected uniform frequency. Green bars fall within 10% of the expected count, amber bars deviate by 10-25%, and red bars deviate by more than 25%. For files larger than a few kilobytes, virtually all bars should be green due to the law of large numbers.

About This Tool

What is a CSPRNG?

A Cryptographically Secure Pseudorandom Number Generator (CSPRNG) produces output that is computationally indistinguishable from true randomness. Unlike Math.random(), which uses deterministic algorithms like xoshiro256** that can be predicted if the internal state is known, a CSPRNG draws from the operating system's entropy pool. On Linux this is /dev/urandom, on Windows it is BCryptGenRandom, and on macOS it is SecRandomCopyBytes.

The Web Crypto API

The crypto.getRandomValues() method is part of the W3C Web Cryptography API, available in all modern browsers since 2014. It fills a typed array with cryptographically strong random values. The specification mandates CSPRNG quality, meaning the output is suitable for generating encryption keys, initialization vectors, nonces, and other security-sensitive values. This tool generates data in 64 KB chunks because the specification limits each call to 65,536 bytes.

Shannon entropy explained

Shannon entropy, defined by Claude Shannon in his 1948 paper "A Mathematical Theory of Communication," quantifies the average information content per symbol. For byte-level analysis, entropy is measured in bits per byte on a scale from 0 to 8. A file where every byte is identical has entropy of 0. A file with perfectly uniform byte distribution has entropy of exactly 8.0 bits per byte (log2(256) = 8). English text typically has entropy around 3.5-4.5 bits per byte due to letter frequency patterns. Compressed files like ZIP or JPEG typically score 7.5-7.9 because compression removes redundancy. Cryptographically random data consistently scores between 7.998 and 8.000.

Byte distribution analysis

The entropy histogram provides a visual chi-squared test of the generator output. In a truly random file of N bytes, each of the 256 possible byte values should appear approximately N/256 times. The standard deviation from the expected count follows a binomial distribution: for a 1 MB file, each byte value should appear about 4,096 times with a standard deviation of roughly 64. Bars that consistently deviate beyond 2-3 standard deviations would indicate a flaw in the random number generator — though with modern CSPRNGs, this is essentially impossible to observe.

Performance architecture

The generator processes data in 64 KB chunks, yielding to the browser's main thread every 1 MB to prevent UI freezing. This streaming approach keeps the page responsive even during 100 MB file generation. Each chunk is immediately tallied into the byte frequency histogram, so entropy statistics are computed incrementally without a second pass over the data. The final file is assembled as a Blob from the chunk array, avoiding the need to concatenate large ArrayBuffers in memory.

Why Use This Tool

When you need random binary files

Random binary files serve as essential test fixtures across software development, systems engineering, and security research. Here are the most common scenarios:

  • Testing file upload handlers — verify that your application correctly handles arbitrary binary data without crashing, truncating, or corrupting the upload. Random files expose edge cases like null bytes, control characters, and sequences that resemble format-specific magic bytes.
  • Benchmarking disk I/O — random data is incompressible, so disk benchmarks using random files measure raw throughput without filesystem or SSD controller compression inflating the numbers. Tools like fio and dd use similar approaches.
  • Network throughput testing — sending random binary data over HTTP, WebSocket, or TCP connections measures true bandwidth without compression algorithms reducing the payload size in transit.
  • Fuzz testing — fuzzing tools like AFL, libFuzzer, and Jazzer feed random data to parsers, deserializers, and protocol handlers to discover crashes, memory corruption, and undefined behavior. A random binary file serves as a starting seed corpus.
  • Encryption testing — verifying that encrypted output has high entropy (close to 8.0 bits/byte) is a basic sanity check for cryptographic implementations. If encrypting a known file produces output with low entropy, the cipher may have a weakness.
  • Secure disk erasure verification — after overwriting a disk with random data, generating a fresh random file and comparing it to the overwritten sectors verifies that the erasure was not deterministic or patterned.
  • CI/CD test fixtures — automated tests often need files of specific sizes to verify upload limits, storage quotas, or memory handling. Generating them on the fly eliminates the need to commit large binary fixtures to version control.

Why browser-based generation matters

Command-line tools like dd if=/dev/urandom of=file.bin bs=1M count=10 require a Unix shell, and Windows users need third-party tools. This browser-based generator works on every platform — Windows, macOS, Linux, ChromeOS, and even mobile devices — with identical CSPRNG quality. The generated files never leave your machine, ensuring complete privacy for sensitive use cases.

Privacy

All random data generation happens entirely in your browser using the Web Crypto API. No data is transmitted to any server. The generated file exists only in your browser's memory until you download it or close the page.

FAQ

How random is the generated data?
The generator uses the Web Crypto API's crypto.getRandomValues() function, which provides cryptographically secure pseudorandom numbers (CSPRNG). On most systems, this draws from the operating system's entropy pool (/dev/urandom on Linux, BCryptGenRandom on Windows). The output passes all standard randomness tests including NIST SP 800-22.
What is the entropy histogram showing?
The histogram displays how many times each possible byte value (0-255) appears in the generated file. For truly random data, all 256 values should appear approximately equally often, producing a flat histogram. The entropy score near 8.0 bits per byte confirms uniform distribution. Any significant deviation from flatness would indicate a bias in the random number generator.
What is the maximum file size I can generate?
The tool supports generating files up to 100 MB in the browser. Files are generated in 64 KB chunks to avoid exhausting browser memory. For very large files, generation may take a few seconds — the progress bar shows real-time status. Files larger than 100 MB may exceed browser memory limits depending on your device.
What are common uses for random binary files?
Random binary files are used for testing file upload handlers, stress-testing parsers and deserializers, benchmarking disk I/O and network throughput, generating encryption keys and initialization vectors, creating test fixtures for unit tests, filling disk space for security erasure verification, and as input for fuzzing tools that test software against random data.