Search for a tool
RLE (Run-Length Encoding)

Tool for encoding / decoding with Run-Length Encoding (RLE), a very basic data compression algorithm that consists in describing a string according to its repetitions.

Results

RLE (Run-Length Encoding) -

Tag(s) : Compression

Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Feedback and suggestions are welcome so that dCode offers the best 'RLE (Run-Length Encoding)' tool for free! Thank you!

# RLE (Run-Length Encoding)

## RLE Decoding

### Parameters

 Format Character then Count (C4 = CCCC) Count then Character (4C = CCCC) Binary (0 first) Binary (1 first)

## RLE Encoding

### Parameters

 Format Character then Count (C4 = CCCC) Count then Character (4C = CCCC)

### What is Run Length Encoding? (Definition)

Run Length Encoding (or RLE, or range encoding) is a data compression (lossless) technique based on successive repetitions of elements.

Run Length means run length , and indeed, with RLE, what matters is the length, the size of the repetitions (in a text, a message, etc.)

RLE is a generic name for this compression technique, several ways to use and implement it exist.

### How to encrypt using RLE compression?

The text to be encoded is scanned to find sequences of identical characters, then note the character and the number of repetitions in the sequence.

Example: DDDDDCCCCOOODDE can be described as 5 times the D character followed by 4 times the C character, etc. The message can therefore be compressed D5C4C3D2E1 (10 characters instead of 15, compression rate: 33%).

This procedure only produces compression if the message consists of many repetitions.

Example: DCODE would be compressed D1C1O1D1E1 (10 characters instead of 5, compression rate: -100%). In order to avoid this kind of case, it is possible to omit the 1 in the case of non-repetitions.

Writing variant

It is possible to encode by reversing the characters and the counts.

Example: 5D4C3C2D1E is then equivalent to D5C4C3D2E1

In case of Binary data

If the message is composed of binary data (0 and 1), then it is possible to use RLE without indicating the character, the numbers are sufficient. The first number indicating the 0 (or the 1), then alternatively.

Example: 00011110000 is coded 3,4,5

Case of Numerical data

If the message is made up of numbers, then use a separator otherwise it will no longer be possible to distinguish the characters from their number of repetitions.

Example: 11111111111122 is coded as '12 -1,2-2 'and not' 12122 'which could be translated as' 1' repeated 2122 times, or 1 times' 2 'followed by 12' times the number '2 ', etc.

### How to decrypt using RLE decompression?

The RLE decompression consists in browsing the message formed of pairs (character, number of repetition) and writing the equivalent text by writing the character the corresponding number of times.

Example: D5C4C3D2E1 decomposes into D5, C4, O3, D2, C1 and repeats the characters the correct number of times: D5 => DDDDD > CCCC, etc. To get DDDDDCCCCOOODDE

Binary data case

Example: 3,4,5 is decoded 00011110000 (or 11100001111 depending on the convention used)

### How to recognize a RLE ciphertext?

A message compressed with RLE is composed of pairs (Character-Number) or triples (Character-Separator-Number).

BMP and PCX image formats use RLE to reduce file size.

## Source code

dCode retains ownership of the "RLE (Run-Length Encoding)" source code. Except explicit open source licence (indicated Creative Commons / free), the "RLE (Run-Length Encoding)" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "RLE (Run-Length Encoding)" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "RLE (Run-Length Encoding)" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

## Cite dCode

The copy-paste of the page "RLE (Run-Length Encoding)" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
RLE (Run-Length Encoding) on dCode.fr [online website], retrieved on 2024-07-18, https://www.dcode.fr/rle-compression

## Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!