Run-length encoding

This online calculator compresses the entered string using the run-length encoding (RLE) method.

Actually, the RLE (Run Length Encoding) compression method is probably the simplest data compression algorithm in which repeated characters (series, i.e. sequences consisting of several identical characters) are replaced by the single character and the number of its repetitions.

The algorithm:

  1. start from the first character
  2. add it to the result string
  3. count the number of repetitions of a character and add this number to the result string
  4. take the next character and repeat until the end of the original string

Example: the string “aaaabbbccd” after encoding the repetitions turns into the string “a4b3c2d1”, so instead of 10 characters we get 8. Compression is obvious!

The calculator below compresses the input string using the RLE method, and also displays the lengths of the original and resulting strings and the rate of data compression in percents.

PLANETCALC, Run-length encoding

Run-length encoding

Digits after the decimal point: 2
RLE String
S4O3E3R2O3A2Y5D4O1E1U5W4J3O1R2U10X3K1H6M6G3L7J4
Length of the original string
83
Length of the encoded string
47
Compression rate
43.37 %

URL copied to clipboard
PLANETCALC, Run-length encoding

Comments