This is a modified fork of sc-compression, tailored specifically for decompressing Clash of Clans game asset files for use in data projects, tooling, and analysis. This version adds support for:
-
Outputting decompressed files to a separate output/ directory instead of overwriting original files
-
An interactive CLI tool to select a file or directory to decompress
-
Cleaner project layout for integration into pipelines (e.g., JSON/SQL conversion)
This module is intended to compress and decompress Supercell assets.
✨ Supported Signatures:
| signature | description | decompression | compression |
|---|---|---|---|
none |
non-compressed file | ✔️ | ✔️ |
lzma |
starts with bytes 0x5d0000 | ✔️ | ✔️ |
sc |
starts with "SC" | ✔️ | ✔️ |
sclz |
starts with "SC" and contains "SCLZ" | ✔️ | ✔️ |
sig |
starts with "Sig:" | ✔️ | ✔️ 🚩 |
sc2 |
starts with "SC" and contains "START" | ✔️ | |
zstd |
contains 0x28b52ffd | ✔️ |
The module automatically infers the right signature when decompress is called.
npm install sc-compression
Decompress a file buffer.
buffer<Buffer> A compressed file that was read into a Node.js Buffer- Returns: <Promise<Buffer>> A decompressed file buffer that can be written to disk
Compress a file buffer.
buffer<Buffer> A file that was read into a Node.js Buffersignature<string>'lzma','sc','sclz'or'sig'. It is impossible to recompress ansigfile with a valid hash, so attempting to load ansigfile in an unpatched game client will crash.- Returns: <Promise<Buffer>> A compressed file buffer that can be written to disk
Read a compressed file signature.
buffer<Buffer> A compressed file that was read into a Node.js Buffer- Returns: <string> The file signature
import { readdir, readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { decompress } from 'sc-compression';
const inputPath = './assets/logic';
const outputPath = './output';
await mkdir(outputPath, { recursive: true });
const files = await readdir('inputPath');
for (const file of files) {
const filepath = resolve(inputPath, file);
const buffer = await readFile(inputPath);
const decompressed = await decompress(buffer);
await writeFile(resolve(outputPath, file + '.csv'), decompressed);
}See tests for additional implementation examples.
- ✅ Install Node.js
- ✅ Open a terminal and run:
npm install -g sc-compression
- ✅ Clone this repository or download
examples/decompress.mjs - ✅ Run the script (within the same directory as decompress.mjs):
node decompress.mjs
- ✅ When prompted, paste the full path to the folder containing game files (e.g.,
C:/Users/you/Desktop/resources/assets/logic) - ✅ Check the
output/folder for decompressed.csvfiles
-
Clash of Clans API and tooling extensions
-
Game data analysis (buildings, upgrades, units)
-
Exporting balance data to JSON, PostgreSQL, or spreadsheets
Thanks for making this tool! I was struggling to get game data!