Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Snappy

From ReverseEngineering.wiki
Format
Magic FF 06 00 00 73 4E 61 50 70 59 (framing format)
Extensions .sz, .snappy
Endianness little-endian
On this wiki Facts · Code · Notes · Topics

Google's fast LZ77-style byte-oriented compression (no entropy coding): raw Snappy blocks start with a varint of the uncompressed length, and the framing format (.sz, stream mode) starts with the 10 bytes FF 06 00 00 'sNaPpY'.

Overview

Snappy (formerly Zippy) trades ratio for speed. Two formats exist: the raw block format (no magic, used inside databases such as LevelDB, RocksDB, Cassandra, Hadoop, Parquet) and the framing format for streams and files.

Raw block format

  • Starts with the uncompressed length as a little-endian base-128 varint (7 bits per byte, high bit = continue). There is no magic, so a block is recognised by context.
  • Then elements: the low 2 bits of the tag byte select literal (00), copy with 1-byte offset (01), copy with 2-byte offset (10) or copy with 4-byte offset (11). Literal lengths up to 60 are in the upper 6 bits; 60-63 mean that 1-4 extra length bytes follow. Source: format_description.txt in the repository.

Framing format

A framed stream is a sequence of chunks: 1 byte type, 3 bytes little-endian length, data.

Type Meaning
0xFF Stream identifier, data = the six bytes 'sNaPpY'. A stream always starts with FF 06 00 00 73 4E 61 50 70 59; it may repeat when streams are concatenated
0x00 Compressed data: 4-byte masked CRC-32C of the uncompressed data, then a Snappy block; at most 65536 uncompressed bytes per chunk
0x01 Uncompressed data: masked CRC-32C then raw bytes (max 65540 chunk length)
0xFE Padding (skippable)
0x02-0x7F Reserved, unskippable (decoder must fail)
0x80-0xFD Reserved, skippable

The checksum is CRC-32C (Castagnoli, polynomial 0x1EDC6F41, reflected 0x82F63B78) masked as ((crc >> 15) | (crc << 17)) + 0xA282EAD8.

The Hadoop/Java 'snappy-java' and Hadoop codecs use a different block stream (4-byte big-endian lengths, no sNaPpY) and snappy-java's own file magic 82 'S' 'N' 'A' 'P' 'P' 'Y' 00: Unverified, from general knowledge.

Related

Library:Snappy, Technique:Identifying compression libraries in binaries.

Code & repositories

  • https://github.com/google/snappy @ 9c28114a38866f6deeaa826db918293bc28ae410 · license: BSD-3-Clause (declared by the contributor; GitHub's detector did not recognize COPYING)
    Reference Snappy source with format_description.txt and framing_format.txt
    Tested on: source read, not run: source only · checked 2026-10-18; last activity 2026-09-18