Adapted from Dean Hickerson's definition, 14 August 2002:

RLE format specification

First line:

x = width, y = length, [rule = B[borndigits]/S[survivedigits]]

Newline delimiter may be [cr], [lf], or [cr][lf] due to different text-format standards for Mac, Unix, and Windows computers.

Following lines:

pattern encoded as [runlength]char[runlength]char... where char is one of:

b: off (blank) o: on (live) $: end of line (note that 5$ is treated as five successive cr/lf) !: end of pattern and runlength is omitted if it = 1.

'[' and ']' are not actually in the text, of course.

Some database maintainers, notably Mark Niemiec, use 'x' and 'y' as alternatives to 'o' to denote different colors, to make distinct subpatterns easier to distinguish.

Newline characters are added as necessary to keep each line at 70 chars or less, and char sequences are never broken.

Any lines of text before the "x =" header line, or after the ! but before the next blank line, are generally considered to be comment text, not relevant to the interpretation of the RLE pattern itself. Comments may be placed either before or after the run-length-encoded pattern, but it's more common to put the comments at the beginning of the pattern (even though many Life programs, e.g., Life32 and MCell, write them at the end).

Comments before the header line are always prefixed at least with '#', almost always with '#C' or '#D', and predominantly with '#C ' or '#D ' (for "comment" and "description" respectively.) Comments after the closing '!' are generally not prefixed by anything.

Some programs (notably MCell, at least up to version 4.20) deal badly with comment lines over 70 characters long -- they may be truncated and/or interpreted as part of a pattern.

Ideally a program should simply ignore any initial lines starting with '#', unless it recognizes them as part of some program-specific extension. If a program wants to save the comments along with the pattern, that's fine.

However, occasionally parameter tags from XLife's much more versatile format will get mixed in with RLE comments, so it's worth mentioning these here. All XLife parameters begin with a '#' (and so are generally treated as comments by RLE decoders.)

Here is the list of Xlife tags, up to version 3.5/3.6, that might be found with RLE:

ignore the entire line
#M [x = xdiam , y = ydiam]
tag needed by Xlife 3.5 as a prefix to RLE header, to recognize RLE format.
this line contains the internal name of the pattern
This line contains information on the person who wrote the file format in the form: id "name"@machine date, for example: "Jon C. R. Bennett" 1990-02-12 18:25:54
this line contains a comment for the user
#r survivedigits/borndigits
Set new rules survivedigits and borndigits are a subset of digits out of the range 0 up to 8 counting the number of neighbours of the central cell
#L x y string
write the string (up to newline character) at the position (x,y)
#U filename
load a rule-set file [only in Eric Raymond's N-state mode]
The following tags specify other non-RLE formats, which almost certainly will not be found with RLE:
#P x,y
starting coordinate for first 'picture-format' cell on following line (however, this has been implemented
'absolute' x,y coordinates follow, separated by newlines
#R [xoff[yoff]]
'relative' x,y,coordinates follow, separated by newlines (i.e., relative to the mouse cursor, in contrast to a coordinate origin)
#D x,y
coordinate differences from the previous point, separated by newlines
#I patternname [xoffset[yoffset[rotate[flip[delay]]]]]
structured format for describing a large pattern in terms of subpatterns
#B name
Beginning of block containing the definition of a subpattern called name in a "library" file
End of pattern block begun by the previous #B tag

The odd case is #D, which is also used in Life 1.05 format but means "description" in that context. Life32 automatically writes description tags containing ugly hexadecimal numbers that provide a checksum of sorts, for Life32's internal use in loading the pattern.

************** link to HK's extended RLE format description (for annotated patterns)? Here's the summary I have:**************

Each layer has an RLE-style header of the form

x=nnn, y=nnn [,h=nnn, v=nnn, color=(rrr,ggg,bbb), gen=nnn, rule=Sn/Bn]
commas and whitespace are optional, but recommended. Either can be a delimiter. h,v = the offset for a particular pattern from the first pattern, postive right, down. Can be used in first layer to specify to Life editor programs absolute position of pattern. color = the color to be used with this layer. Default is 2nd layer green (0,255, 0) and 3rd layer blue (0, 0, 255). Layers after that are undefined. Values are decimal. gen = Used by Life editor programs, ignored in lifeviewer. rule = Used by Life editor programs , ignored in lifeviewer.
Following the last layer are formatting commands, one per line.
GP {NW | SW | NE | SE | N | S | E | W} X="nnn", Y="nnn", LEN="nnn", COLOR=(rrr,ggg,bbb)
Glider path: Starting at specified cell, draw a 1 pixel wide line in the direction and length in cells specified. (Not yet implemented for spaceships (NSEW).) COLOR -- optional. Default is (255, 255, 0), yellow.
G {NW | SW | NE | SE | N | S | E | W} X="nnn", Y="nnn", COLOR=(rrr,ggg,bbb)
Glider -- Draw a small (4x4 pixels) arrow in the specified direction at the specified cell. COLOR -- optional. Default is (255, 0, 0), red. (Actually, not implemented)
VL vvv, [{*|ttt}, {*|bbb}, COLOR=(rrr,ggg,bbb)
Vertical line -- Draw cell wide vertical line. ttt and bbb parameters specify top and bottom, with "*" meaning image edge. if not specified, equivalent to "*". COLOR -- optional. Default is (200, 200, 200)
HL hhh, [{*|rrr}, {*|lll}, COLOR=(rrr,ggg,bbb)
Horizontal line -- See Vertical line
CB lll, ttt, rrr, bbb, KEY="xxx"
Cell Border -- expand image size by the number of cells specified. Affects any "*" params in other format commands. KEY -- Optional, Only display title value matches CGI "&drawkey=" parameter.
A {NW | SW | NE | SE | N | S | E | W} X=nnn, Y=nnn
Arrow -- draw a gray 13x13 pixel arrow image centered on the cell specified. (Arrow image should be transparent someday. but currently has a white border. Also, a URL might be nice.)
L cc X=nnn, Y=nnn, TEXT="xxx", SIZE=nn, COLOR=(rrr,ggg,bbb)
Label: cc -- two character code specifying how the label is to be drawn from the specified cell center. Either order, but must be at least one of each of the following triplets: L Left R Right C Center T Top B Bottom M Middle SIZE -- Optional Font size, default = 9 COLOR -- Optional. Default is (0,0,0) Black.
FR LIST=(xxx,yyy),(xxx,yyy)... , COLOR=(rrr,ggg,bbb)
Frame -- Draw a one pixel wide frame from the given list of cells. List must be closed manually to complete a polygon. COLOR -- Optional. Default is (0,96,192).
T {T|B} TEXT="xxx" SIZE=nn COLOR=(rrr,ggg,bbb) KEY="xxx"
Title -- draw a centered title T | B -- Position title at top or bottom, required SIZE -- Optional Font size, default = 9 COLOR -- Optional. Default is (0,0,0) Black. KEY -- Optional. Only display title value matches CGI "&drawkey=" parameter.
R {*|lll}, {*|ttt}, {*|rrr}, {*|bbb}, COLOR=(rrr,ggg,bbb)
Rectangle -- Fill the selected set of cells with the color selected. * -- use value that would extend rectangle to edge. COLOR -- optional. Default is (200, 200, 200)

Picture format:

Picture format is an uncompressed encoding of a pattern, with one character per cell. Generally each OFF cell is encoded with a . (or occasionally a space) and each ON cell is represented by one or more of [Oo*%@#x] -- sometimes alternate characters are used for specially-marked subpatterns. Also, | / - \ characters may denote a line of symmetry, and X's may be used to mark 'don't care' cells -- but it's not usually expected that such patterns will be readable by computer programs.