Building Zero-Upload Browser Tools: 75% STL Mesh Compression & Local PDF Merging in Vanilla JS
Most online PDF mergers, image compressors, and 3D model utilities force you to upload files to a remote server, wait in a queue, and hit paywalls or file-size limits. For sensitive PDFs (contracts, invoices, tax forms)
Most online PDF mergers, image compressors, and 3D model utilities force you to upload files to a remote server, wait in a queue, and hit paywalls or file-size limits. For sensitive PDFs (contracts, invoices, tax forms) or bulky 50MB+ ASCII STL meshes from CAD exports, uploading makes zero senseβmodern browsers already have ArrayBuffer, DataView, Canvas, and Web APIs that process these files in milliseconds locally.
I put together LocalVault Tools β a lightweight, zero-backend suite of browser utilities where files never leave your device. Here is a quick breakdown of how the three core tools work under the hood.
1. Shrinking 3D Printing STL Files by ~75% with DataView
Many CAD tools export ASCII STL files that look like this:
solid model
facet normal 0 0 1
outer loop
vertex 0.0 0.0 0.0
vertex 10.0 0.0 0.0
vertex 0.0 10.0 0.0
endloop
endfacet
endsolid model
ASCII STL is easy to read, but bloated. Binary STL packs every triangle into exactly 50 bytes:
-
12 bytesβ 3 Γfloat32facet normal -
36 bytesβ 9 Γfloat32vertices (3 points) -
2 bytesβuint16attribute byte count
Writing a binary STL directly into an ArrayBuffer via DataView takes ~30 lines of vanilla JavaScript:
const buffer = new ArrayBuffer(84 + triangles.length * 50);
const view = new DataView(buffer);
view.setUint32(80, triangles.length, true); // little-endian triangle count
let offset = 84;
for (const tri of triangles) {
for (const val of [...tri.normal, ...tri.v1, ...tri.v2, ...tri.v3]) {
view.setFloat32(offset, val, true);
offset += 4;
}
view.setUint16(offset, 0, true);
offset += 2;
}
At the same time, you can compute the exact signed tetrahedral volume ((v1 Β· (v2 Γ v3)) / 6), surface area, bounding box dimensions (mm), and estimated PLA/PETG/ABS filament weight without WebGL or heavy 3D engines.
- Try it live: STL Mesh Analyzer & ASCII-to-Binary Compressor
2. Client-Side PDF Merge, Split & Images-to-PDF
Using pdf-lib directly in the browser avoids uploading private documents:
- Load each PDF as an
ArrayBufferviafile.arrayBuffer(). - Copy pages into a new
PDFDocument(mergedPdf.copyPages(srcPdf, indices)). - Export with
await mergedPdf.save()and trigger a localBlobdownload. For Images-to-PDF, embed PNG/JPG bytes with
embedPng/embedJpgand auto-size each page to match the image aspect ratio.Try it live: Local PDF Merge, Split & Images-to-PDF
3. Batch WebP / JPEG Compression with Canvas + JSZip
For bulk image optimization (product photos, blog assets, screenshots):
- Decode each image locally with
createImageBitmap(file)(orImagefallback). - Draw onto an offscreen
<canvas>with optional max-width scaling. - Encode with
canvas.toBlob(cb, 'image/webp', quality)and show instant before/after byte savings. Bundle all compressed files into a single
.zipdownload withJSZip.Try it live: Batch Image Compressor (WebP/JPEG + ZIP)
Source Code & Live Demo
Everything is static HTML/CSS/JS hosted on GitHub Pages with zero tracking cookies and zero file uploads:
- Live Site: https://devbox-zero-ops.github.io/localvault-tools/
- Source Code (MIT): https://github.com/devbox-zero-ops/localvault-tools
If you have other everyday file utilities you wish worked 100% locally in the browser, drop them in the comments!
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.