Free Online Utility • Binary Studio • Base-2 Engine

RLE Encode a Binary Number

Compress binary bitstreams using Run-Length Encoding (RLE) with multiple notation formats and live compression ratio stats.

Formula & Quick Reference Base-2 Engine
Consecutive identical bits -> (run_length, bit_value)
0000000011111 -> 8:0 5:1  (13 bits -> 2 runs)
Long RunsHigh compression ratio
Alternating 1010Worst case (1 bit/run)
Lossless100% exact reconstruction
RUN-LENGTH ENCODER (RLE)
Compressed RLE Output

        
100% client-side exact Binary Engine Instant

Session Calculation Log

No entries recorded in this session yet.

How RLE Encode a Binary Number Works

RLE Encode a Binary Number compresses repetitive binary bitstreams into lossless run-length tokens across four industry-standard formats including classic Fax alternating-run notation and JSON.

Binary arithmetic and base-2 encoding form the physical foundation of digital microprocessors, network packets, memory buffers, and cryptographic primitives. Every calculation in this utility runs directly inside your browser using exact JavaScript BigInt and typed-array pipelines, so arbitrary-length bitstreams, 128-bit addresses, and raw byte buffers never suffer from 53-bit IEEE floating-point truncation or server latency.

Lossless Binary Run-Length Compression

Scan left-to-right: replace k consecutive copies of bit b with token (k, b)
Fax Optimization: store only initial bit + sequence of alternating run lengths!

Because binary has only two symbols (0 and 1), once the starting bit is known every subsequent run automatically toggles polarity — the exact principle behind ITU-T Group 3/4 fax compression.

Worked Reference Examples

InputOutputStep / Bit Note
00000000111118:0 5:113 bits -> 2 runs (avg 6.5)
Fax format0, 8, 5Initial bit 0, then alternating lengths
101010101:1 1:0 1:1 ...Alternating bits do not compress

Practical Engineering Applications

1-Bit Image & Fax Compression

Encode monochrome bitmap scanlines efficiently before transmission.

Compression Benchmarking

Measure average run length to decide whether RLE or Huffman/LZ77 fits your bitstream.

Precision, Edge Cases & Best Practices

Pairs directly with our RLE Decode a Binary Number tool for instant round-trip verification.

All input parsing strips harmless formatting whitespace, underscores, or common prefixes such as 0b where applicable, while preserving exact bit order and padding width so outputs drop straight into C/C++, Rust, Verilog, VHDL, Python, and embedded firmware test harnesses.

Frequently Asked Questions

Why is binary RLE even more compact in Fax mode?
Because a binary stream strictly alternates between 0-runs and 1-runs, storing just the first bit followed by run lengths eliminates storing the bit label for every subsequent run.
When does RLE fail to compress binary data?
High-entropy or alternating streams (like 10101010) have average run length ≈ 1–2, which expands rather than shrinks under RLE.
Is RLE compression lossless?
Yes — decoding recovers every single original bit with 100% fidelity.