Zero-WASM SQLite3 & Apache Parquet Binary Parsing in Browser Memory

By Bastien Sulyan · November 2026 · Binary Formats & Storage Engines

Inspecting a .sqlite database snapshot or an Apache .parquet analytics dump in the browser often relies on heavyweight WebAssembly builds that take several megabytes to download and initialize. For read-only schema inspection, filtering, and multi-format export, pure TypeScript decoders operating directly over Uint8Array and DataView parse both formats deterministically in milliseconds with minimal bundle size and zero server uploads.

This architecture powers both the Sunasty SQLite Viewer and the Sunasty Parquet Viewer for files up to 100 MB strictly inside client memory.

1. SQLite 3 Header, 1-to-9 Byte Varints & Record Unpacking

A valid SQLite 3 database begins with the 16-byte magic sequence "SQLite format 3\0" followed by a 100-byte big-endian database header. Byte offsets 16..17 store the 16-bit page size (where raw value 1 denotes 65,536 bytes), offset 56 selects text encoding (UTF-8, UTF-16le, or UTF-16be), and offset 96 encodes the SQLite library version integer.

export function readSqliteVarint(bytes, offset) {
  let value = 0;
  const maxLen = Math.min(9, bytes.byteLength - offset);
  for (let i = 0; i < maxLen; i++) {
    const byte = bytes[offset + i];
    // The 9th byte uses all 8 bits instead of 7 payload bits + continuation bit
    if (i === 8) {
      return { value: value * 256 + byte, byteLength: 9 };
    }
    value = value * 128 + (byte & 0x7f);
    if ((byte & 0x80) === 0) {
      return { value, byteLength: i + 1 };
    }
  }
  return { value, byteLength: Math.max(1, maxLen) };
}

Traversing Page 1 (sqlite_schema) and user tables inspects B-tree interior table pages (flag 0x05) and leaf table pages (flag 0x0d). Each cell payload packs a record header varint list specifying serial types: codes 0..9 decode fixed signed big-endian integers, IEEE-754 Float64, or constants 0 / 1, while codes >= 12 map directly to variable-length byte slices of size (st - 12) / 2 for BLOBs (even codes) and (st - 13) / 2 for text strings (odd codes). Paired with DDL extraction (parseCreateTableDdl), the viewer surfaces column affinities, primary keys, foreign keys, a hex/ASCII BLOB drawer, and read-only SELECT filtering.

2. Apache Parquet PAR1 Footer & Selective Column Projection

Unlike row-oriented formats, Apache Parquet places metadata at the end of the binary stream. Validation checks the 4-byte "PAR1" magic header at offset 0, the trailing "PAR1" marker at byteLength - 4, and the little-endian 32-bit footerLength immediately before it:

export function validateParquetMagicBytes(bytes) {
  if (bytes.byteLength < 12) return { valid: false, footerLength: 0, footerOffset: 0 };
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
  const PAR1 = 0x31524150; // "PAR1" little-endian
  if (view.getUint32(0, true) !== PAR1 || view.getUint32(bytes.byteLength - 4, true) !== PAR1) {
    return { valid: false, footerLength: 0, footerOffset: 0 };
  }
  const footerLength = view.getUint32(bytes.byteLength - 8, true);
  if (footerLength === 0 || footerLength > bytes.byteLength - 12) {
    return { valid: false, footerLength, footerOffset: 0 };
  }
  return { valid: true, footerLength, footerOffset: bytes.byteLength - 8 - footerLength };
}

From footerOffset, a lightweight Thrift Compact Protocol reader decodes FileMetaData using LEB128 varints and ZigZag signed integers to recover the schema tree, RowGroup offsets, dictionary page positions, compression codecs (UNCOMPRESSED, Snappy block framing, and GZIP via fflate), and per-column min/max statistics. Because each ColumnChunk offset is stored independently inside RowGroupMetaData, checking a subset of columns in the UI only seeks and decompresses those selected column chunks.

3. Related Data & Privacy Utilities

Export inspected tables locally as CSV, TSV, JSON, JSONL, Markdown, or SQL, then clean sensitive columns with the client-side PII Redactor, transform formats with the Data Converter, reconcile exports in CSV Reconcile, or format queries in the SQL Formatter.