{
  "id": 21600989,
  "title": "Why I moved my file tools to the browser (and what broke along the way)",
  "url": "https://urgent.news/2026/11/24/why-i-moved-my-file-tools-to-the-browser-and-what-broke-along-the-way",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-24T13:34:32.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mikedevitools/why-i-moved-my-file-tools-to-the-browser-and-what-broke-along-the-way-3i3m"
  },
  "original_language": "en",
  "account": "In his journey to move file tools to the browser, the author encountered several challenges. Initially, they aimed to build deviTools with the rule that if the browser can handle the task, the file should never leave the tab. This approach has its advantages, such as reduced server storage and improved privacy.\n\nThe author first tackled image conversion using Canvas, which allows decode and encode operations to occur within a Worker. This enables the processing of large images like 40 MP photos without freezing the user interface. However, some issues arose during this process. For instance, converting a transparent PNG to JPEG caused alpha channel loss, as JPEG silently composites transparent areas onto black. To address this, the author had to manually fill the canvas with white before drawing. Additionally, EXIF orientation information was not automatically preserved when using createImageBitmap; it required a specific flag to be set. Furthermore, HEIC files are only decoded by Safari without additional decoding, which led to the creation of a WASM decoder for HEIC/HEIF to maintain the privacy promise.\n\nMoving on to diffing, the author discovered that building one DOM node per line for each side proved inefficient. Scaling to 5,000 lines would result in 10,000 nodes plus intra-line highlight spans, causing scrolling issues. The solution was to virtualize the viewport, rendering around 60 rows and translating a spacer to accommodate the entire dataset. The main thread handled rendering, while the Worker performed the diff algorithm, which is relatively straightforward. To improve performance further, the author computed intra-line character diffs only for rows currently visible and normalized line endings before comparison to avoid confusion between different line ending formats.\n\nWhen it came to JSON handling, the author learned that JSON.parse is not an ideal validator. While it tells you if parsing failed, it provides minimal information about where the error occurred, and the error messages differ across engines. To create a more user-friendly error message, the author implemented their own tokenizer or extracted the position from the error message and reconstructed the line and column information. Additionally, JSON.parse accepts duplicate keys, which can lead to unexpected behavior in configuration files. Implementing a format/validate tool that explicitly warns about duplicate keys can prevent real bugs from going unnoticed.\n\nLastly, the author acknowledged the limitations of client-side processing. Large files exceeding a few hundred MB may challenge memory limitations on different devices, so the author caps file sizes and informs users about these restrictions. Furthermore, certain tasks like rendering complex documents require a real font/layout engine, which is not feasible entirely in the browser. In such cases, the author suggests using a server step to handle these specific requirements. Overall, the author emphasizes that client-side-first development is a practical approach, focusing on leveraging platform APIs and addressing the more challenging aspects, such as orientation flags, alpha channels, line endings, and duplicate keys.",
  "summary": "Every \"convert HEIC to PNG\" or \"compare two files\" site I used had the same quiet problem: my file went to someone's server. For a holiday photo, fine. For a client contract or a production config dump, not fine. So when I started building deviTools , I set one rule: if the browser can do the work, the file never leaves the tab. Here's what that actually takes, and where the rule had to bend. 1.…",
  "key_points": [
    "Author moved file tools to browser to reduce server storage and improve privacy.",
    "Encountered issues with image conversion, diffing, and JSON handling in browser processing."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}