Blog

Export to SPSS (.sav)

The new SPSS extension converts any Jspreadsheet worksheet into a native SPSS .sav file, which can be opened directly in SPSS, PSPP, and any tool that reads the PSPP system file format — column types, formats, value labels, and measure levels are automatically converted.

icon jspreadsheet

Published on April 23, 2026

Introducing

@jspreadsheet/spss is a Jspreadsheet extension that writes directly from the browser or Node.js to SPSS system files (.sav). It takes your existing column configuration — dropdown lists, calendars, numbers, percentages, checkboxes — and generates a fully typed SPSS dataset with value labels, variable labels, display width, alignment, and measure levels all correctly set.

No external dependencies, no server round trips: the extension outputs a plain binary Uint8Array that can be directly downloaded or saved to disk.

Export to SPSS

New features?

A brand new extension that can be registered with a single line of code, and comes with two helper functions attached to every worksheet.

downloadSav and generateSav

Once the extension is registered, every worksheet receives two helper functions — downloadSav to trigger the browser download, and generateSav to retrieve the raw binary data.

jspreadsheet.setExtensions({ spss });

// In the browser — download directly
worksheet.downloadSav({ filename: 'survey.sav' });

// In Node.js or a Worker — get the bytes
const binary = worksheet.generateSav({ fileLabel: 'Survey' });

Automatic type mapping

Column types are automatically converted to the correct SPSS variables without additional configuration:

  • number, numeric, percent, autonumber → numeric variables whose width and decimal places are inferred from the column's format attribute.
  • calendar → SPSS date value (seconds since 1582-10-14), written as DATE11 or DATETIME22 depending on whether the format includes a time component.
  • dropdown / autocomplete using { id, name } numeric data sources → nominal numeric variables with value labels wired up automatically.
  • checkbox / radio → numeric values 0/1 with No / Yes value labels.
  • text, html, email, url, tags, color, image, notes → string variables with length determined by the longest cell; long strings use line continuation.
  • rating, progressbar → ordinal numeric variables.

The header becomes the full variable name; after sanitization, an 8-character uppercase short name is generated to comply with SPSS's strict naming rules.

Value labels, variable labels and comments

This extension outputs a complete SPSS dictionary, not just the raw values:

  • Dropdown sources are written as correct SPSS value labels, so the label text appears in SPSS/PSPP instead of the raw IDs.
  • Column headers become variable labels on long names.
  • Worksheet comments are preserved in the document record with cell references as keys.
  • Display width, alignment, and measurement level (nominal/ordinal/scale) are set according to the column type.

Works in both browser and Node.js environments

The output is a pure Uint8Array, so the same call runs anywhere:

  • BrowserdownloadSav builds a Blob and triggers a download, requiring no additional libraries.
  • Node.jsgenerateSav returns the bytes directly, which can be passed to fs.writeFile in a backend export pipeline.
  • Raw datasetsspss.generate(data, { headers, columns }) accepts a plain data[][] array, so you can generate a .sav file without instantiating a spreadsheet.

Standards-compliant output

The file conforms to the PSPP System File Format specification:

  • Encoding: UTF-8 (character code 65001)
  • Compression: bytecode compression (opcode blocks with an offset of 100)
  • Dictionary: contains variable records, value label records, document records, long variable names, display parameters, and encoding extension records.

This means the generated .sav file can be opened correctly in SPSS, PSPP, and any third-party reader that supports this format.

Useful links

Export to SPSS Documentation
Jspreadsheet Examples