Every software engineer uses utility websites. We format API responses, decode JWT authentication headers, test regular expressions, and convert binary assets to Base64.
Open Chrome DevTools on most utility sites and check the Network tab. When you paste an authorization bearer token or upload a 10MB document, the page makes a POST request sending your data to an external server. That backend processes the string and returns the formatted response.
Even if the site owner has good intentions, server-side utility processing creates liabilities. Payloads get written to web server access logs, reverse proxy buffers, and temporary directories. If someone pastes customer records or private API tokens into a formatter, that data leaves their control.
We built PrivaUtils to eliminate that risk entirely. It contains single-purpose utilities for coding, PDF processing, text manipulation, and cryptography. Every tool executes directly on the client machine using Web Workers, WebAssembly, and native WebCrypto.
Here is how we handled the three main technical problems of doing everything client-side.
1. The 64-Bit Integer Problem in JSON
A subtle issue with web JSON formatters is how JavaScript handles numbers.
Standard JavaScript numbers follow IEEE 754 double-precision floating-point format. The safe integer boundary is:
Number.MAX_SAFE_INTEGER; // 9,007,199,254,740,991 (2^53 - 1)
Modern backends frequently use 64-bit integers for database IDs, Discord Snowflake IDs, and Twitter message IDs. A typical 64-bit ID looks like this:
{
"user_id": 9223372036854775807
}
If you run standard JSON.parse() on that payload in a browser or Node.js environment:
const data = JSON.parse('{"user_id": 9223372036854775807}');
console.log(data.user_id);
// Output: 9223372036854776000
The last three digits are rounded. If an engineer formats a payload, copies the result, and pastes it into Postman or a database query, the record lookups fail.
In our JSON Formatter, we bypass JSON.parse for number tokens. We tokenize raw numeric sequences with json-bigint, storing integers above Number.MAX_SAFE_INTEGER as native JavaScript BigInt objects. The tree view, search filters, and minifiers retain the exact string value of the number without float conversion.
2. Preventing Browser Freezes from ReDoS
Regular expression matching in client-side tools creates a Denial of Service risk. If a user pastes a nested quantifier like (a+)+$ and tests it against aaaaaaaaaaaaaaaaaaaaaaaaaaaaab, the regex engine enters catastrophic backtracking.
Because computation runs in the user's browser, a runaway loop freezes the UI thread and crashes the tab.
To solve this in our RegEx Tester, evaluations never run on the main UI thread. They run inside an isolated Web Worker wrapped in an un-hijackable timer:
export function runRegexWithTimeout(
pattern: string,
flags: string,
corpus: string,
timeoutMs: number = 200
): Promise<MatchResult[]> {
return new Promise((resolve, reject) => {
const worker = new Worker(new URL('./regex.worker.ts', import.meta.url));
const watchdog = setTimeout(() => {
worker.terminate();
reject(new Error('Evaluation cancelled: possible catastrophic backtracking (ReDoS).'));
}, timeoutMs);
worker.onmessage = (event) => {
clearTimeout(watchdog);
worker.terminate();
resolve(event.data);
};
worker.onerror = (err) => {
clearTimeout(watchdog);
worker.terminate();
reject(err);
};
worker.postMessage({ pattern, flags, corpus });
});
}
If regex evaluation takes longer than 200 milliseconds, the main thread terminates the worker instance. The browser tab stays responsive at 60 FPS, and the user gets an explicit timeout diagnostic.
3. Zero-Copy Binary Buffers for PDF Manipulation
Document tools like PDF mergers and splitters typically require massive server memory. A multi-page PDF with embedded images can easily consume 40MB of RAM.
In our PDF Merger and PDF Splitter, we use pdf-lib compiled to WebAssembly. The problem with running large file operations in Web Workers is buffer cloning.
If you pass a 40MB ArrayBuffer from the main thread to a worker via standard postMessage, JavaScript clones the entire memory block. Your browser memory consumption doubles instantly, which causes crashes on mobile browsers.
We solved this using Transferable Objects:
// The second argument transfers ownership instead of cloning
const buffer = await file.arrayBuffer();
worker.postMessage({ action: 'MERGE_PDFS', buffer }, [buffer]);
Once transferred, the memory buffer in the main thread becomes detached (zero bytes). The worker takes direct ownership of the allocated RAM. When the compiled PDF is ready, the worker transfers the output buffer back to the main thread and creates an ephemeral Blob URL (blob:https://privautils.com/...) for instant download.
No bytes ever leave the client machine.
Architecture Summary
Modern browsers have mature APIs:
- WebCrypto SubtleCrypto: Hardware-isolated SHA-256, SHA-512, and HMAC signing without external JS cryptography libraries.
- Comlink & Web Workers: Clean RPC interfaces that keep heavy operations off the DOM.
- OffscreenCanvas: Image resizing and format conversion on background threads.
You can inspect all tools and test the implementation directly at privautils.com. The source code is public on GitHub at github.com/privautils/PrivaUtils.
Top comments (0)