<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mike</title>
    <description>The latest articles on DEV Community by Mike (@mikedevitools).</description>
    <link>https://dev.to/mikedevitools</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4262731%2F8488c169-f820-462c-9834-387e371ce895.png</url>
      <title>DEV Community: Mike</title>
      <link>https://dev.to/mikedevitools</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mikedevitools"/>
    <language>en</language>
    <item>
      <title>How to tell if a PDF has been edited (and what the file itself gives away)</title>
      <dc:creator>Mike</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:41:24 +0000</pubDate>
      <link>https://dev.to/mikedevitools/how-to-tell-if-a-pdf-has-been-edited-and-what-the-file-itself-gives-away-4g7j</link>
      <guid>https://dev.to/mikedevitools/how-to-tell-if-a-pdf-has-been-edited-and-what-the-file-itself-gives-away-4g7j</guid>
      <description>&lt;p&gt;Someone sends you an invoice, a signed contract, or a bank statement as a PDF. Is it the file that was originally produced, or has someone been in it since?&lt;/p&gt;

&lt;p&gt;PDFs are unusually talkative about this. The format was designed so that edits get &lt;strong&gt;appended&lt;/strong&gt; rather than rewritten, which means a modified file often carries its own history inside it. Here's what to look for, and where the signals lie to you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The big one: incremental updates
&lt;/h2&gt;

&lt;p&gt;A PDF ends with a cross-reference table, a trailer, and the marker &lt;code&gt;%%EOF&lt;/code&gt;. When a well-behaved editor changes something, it doesn't rewrite the file — it appends the changed objects, a new xref section, a new trailer, and a second &lt;code&gt;%%EOF&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the crudest possible check is just counting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;countRevisions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextDecoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'latin1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/%%&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More than one &lt;code&gt;%%EOF&lt;/code&gt; means the file has more than one revision. The trailer tells you how they chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight postscript"&gt;&lt;code&gt;&lt;span class="n"&gt;trailer&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;Size&lt;/span&gt; &lt;span class="mi"&gt;412&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;Root&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;Prev&lt;/span&gt; &lt;span class="mi"&gt;85213&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;A1B2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;9F&lt;/span&gt;&lt;span class="mf"&gt;8E&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/Prev&lt;/code&gt; is a byte offset pointing back at the previous xref section. Follow that chain and you can count the revisions and, with a bit more work, reconstruct what each one looked like — the earlier version of the text is frequently still sitting in the file, unreferenced but intact.&lt;/p&gt;

&lt;p&gt;That last part is what surprises people. "Deleting" a paragraph in many editors just means the new revision stops pointing at the old object. The bytes don't go anywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  The /ID pair
&lt;/h2&gt;

&lt;p&gt;That &lt;code&gt;/ID&lt;/code&gt; array in the trailer holds two strings. Per the spec, the &lt;strong&gt;first&lt;/strong&gt; is a permanent identifier assigned when the file was created and should survive edits; the &lt;strong&gt;second&lt;/strong&gt; is updated each time the file changes. If the two differ, the file has been modified since creation. If a tool has rewritten both to be identical on a file with multiple revisions, that's its own kind of signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metadata that contradicts itself
&lt;/h2&gt;

&lt;p&gt;The document info dictionary and the XMP metadata both carry timestamps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight postscript"&gt;&lt;code&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;CreationDate&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;D&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20260103142211&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;05&lt;/span&gt;&lt;span class="s1"&gt;'00'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;ModDate&lt;/span&gt;      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;D&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20261118091455&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;05&lt;/span&gt;&lt;span class="s1"&gt;'00'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;Producer&lt;/span&gt;     &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Acrobat&lt;/span&gt; &lt;span class="nc"&gt;Distiller&lt;/span&gt; &lt;span class="mf"&gt;11.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things worth checking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ModDate&lt;/code&gt; later than &lt;code&gt;CreationDate&lt;/code&gt; — modified, obviously.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Producer&lt;/code&gt; or &lt;code&gt;Creator&lt;/code&gt; naming a different tool than the one that made the rest of the file's structure. An invoice generated by a reporting library that now says it was produced by a desktop PDF editor is a strong tell.&lt;/li&gt;
&lt;li&gt;The info dictionary and the XMP packet disagreeing with each other. Some editors update one and forget the other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is tamper-proof — all of it is editable. Which is exactly why you check it against the structural evidence rather than trusting it alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Font subsets
&lt;/h2&gt;

&lt;p&gt;This one is subtle and hard to fake accidentally. PDF producers usually embed &lt;strong&gt;subsets&lt;/strong&gt; of fonts — only the glyphs actually used — and tag them with a six-letter prefix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight postscript"&gt;&lt;code&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;BaseFont&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="no"&gt;ABCDEF&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nc"&gt;Helvetica&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When someone edits text in an existing PDF, the editor often can't extend the original subset, so it embeds a second subset with a different prefix, or falls back to a system font. A document where one line of a paragraph uses &lt;code&gt;/XYZWVU+Helvetica&lt;/code&gt; while every other line uses &lt;code&gt;/ABCDEF+Helvetica&lt;/code&gt; is telling you which line was retyped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cover-ups
&lt;/h2&gt;

&lt;p&gt;The low-effort redaction: draw a white rectangle over a number. The original text is still in the content stream, still extractable, sitting underneath a filled path. If you extract the text layer and find values that don't appear in the rendered page — or find text whose position overlaps an opaque filled rectangle drawn after it — you've found a cover-up rather than an edit.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does &lt;em&gt;not&lt;/em&gt; prove tampering
&lt;/h2&gt;

&lt;p&gt;This is the part most "is my PDF edited" write-ups skip, and it's where false accusations come from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linearization&lt;/strong&gt; (optimising a PDF for web view) rewrites structure and can produce multiple revisions on a file nobody edited.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Digital signatures&lt;/strong&gt; are &lt;em&gt;implemented&lt;/em&gt; as incremental updates. A signed PDF has at least two revisions by design. More revisions after the signature is the thing to look at, not the count itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scanners and OCR&lt;/strong&gt; routinely re-save and add a text layer, changing &lt;code&gt;Producer&lt;/code&gt; and &lt;code&gt;ModDate&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password removal or flattening&lt;/strong&gt; changes the file wholesale without touching a word of content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So "this PDF has three revisions" is a question, not a verdict. The useful output is &lt;em&gt;what changed between them&lt;/em&gt;, which is why comparing the reconstructed revisions beats counting them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing it without uploading the file
&lt;/h2&gt;

&lt;p&gt;The awkward part of all this is that the documents you most want to check — contracts, statements, medical records — are exactly the ones you shouldn't be uploading to a random website to find out.&lt;/p&gt;

&lt;p&gt;That's the itch I built &lt;a href="https://pickypdf.com" rel="noopener noreferrer"&gt;PickyPDF&lt;/a&gt; to scratch: the PDF parsing all runs in the browser, so the file never leaves the device. The &lt;a href="https://pickypdf.com/pdf-edit-checker" rel="noopener noreferrer"&gt;PDF Edit Checker&lt;/a&gt; walks the &lt;code&gt;/Prev&lt;/code&gt; chain, reconstructs the earlier revisions, and diffs the text between them so you can see what actually changed, instead of a yes/no that you have to take on faith. The rest of the &lt;a href="https://pickypdf.com" rel="noopener noreferrer"&gt;PDF tools&lt;/a&gt; work the same way — no upload, no account.&lt;/p&gt;

&lt;p&gt;If you want to poke at the structure yourself first, &lt;code&gt;qpdf --qdf --object-streams=disable file.pdf out.pdf&lt;/code&gt; will decompress a PDF into something you can read in a text editor. It's a genuinely good afternoon.&lt;/p&gt;

&lt;p&gt;What's the weirdest thing you've found buried in a PDF?&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>javascript</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I moved my file tools to the browser (and what broke along the way)</title>
      <dc:creator>Mike</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:34:32 +0000</pubDate>
      <link>https://dev.to/mikedevitools/why-i-moved-my-file-tools-to-the-browser-and-what-broke-along-the-way-3i3m</link>
      <guid>https://dev.to/mikedevitools/why-i-moved-my-file-tools-to-the-browser-and-what-broke-along-the-way-3i3m</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;So when I started building &lt;a href="https://devitools.com" rel="noopener noreferrer"&gt;deviTools&lt;/a&gt;, 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Image conversion: Canvas gets you most of the way
&lt;/h2&gt;

&lt;p&gt;The naive version is almost embarrassingly short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'image/png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quality&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.92&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OffscreenCanvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2d'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drawImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convertToBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quality&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;createImageBitmap&lt;/code&gt; + &lt;code&gt;OffscreenCanvas&lt;/code&gt; means the decode and the encode can both happen inside a Worker, so a 40 MP image doesn't freeze the UI. &lt;code&gt;convertToBlob&lt;/code&gt; handles PNG, JPEG and WebP in every current browser.&lt;/p&gt;

&lt;p&gt;Three things bit me:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alpha channel loss.&lt;/strong&gt; Converting a transparent PNG to JPEG silently composites onto black. You have to fill the canvas yourself before drawing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'#ffffff'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;EXIF orientation.&lt;/strong&gt; &lt;code&gt;createImageBitmap&lt;/code&gt; ignores it unless you ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;imageOrientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'from-image'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without that flag, phone photos come out rotated and users assume your tool is broken.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HEIC.&lt;/strong&gt; Safari decodes it, nothing else does. This is the first place the rule bent — I ship a WASM decoder for HEIC/HEIF rather than uploading the file, which costs a ~1 MB lazy-loaded chunk but keeps the privacy promise. I only fetch it when a &lt;code&gt;.heic&lt;/code&gt; actually lands in the picker. (That path is live on the &lt;a href="https://devitools.com/image-converter" rel="noopener noreferrer"&gt;image converter&lt;/a&gt; if you want to see what the tradeoff feels like in practice.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AVIF encoding&lt;/strong&gt; is still the gap. Decode support is broad; &lt;code&gt;convertToBlob({ type: 'image/avif' })&lt;/code&gt; is not. Feature-detect instead of assuming:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convertToBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'image/avif'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;supported&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'image/avif'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// otherwise you got a PNG&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last line matters — browsers don't throw, they just hand back a PNG with a straight face.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Diffing: the algorithm is the easy part
&lt;/h2&gt;

&lt;p&gt;I expected the diff itself to be the hard bit. Myers diff is well documented and a line-level implementation over a few thousand lines runs in single-digit milliseconds.&lt;/p&gt;

&lt;p&gt;The expensive part is &lt;strong&gt;rendering&lt;/strong&gt;. My first version built one DOM node per line per side. At 5,000 lines that's 10,000 nodes plus intra-line highlight spans, and scrolling died.&lt;/p&gt;

&lt;p&gt;What fixed it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Virtualise the viewport.&lt;/strong&gt; Render ~60 rows, translate a spacer. Obvious in hindsight, easy to skip when your test file is 200 lines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diff on a Worker, render on the main thread.&lt;/strong&gt; Post back a compact array of ops (&lt;code&gt;[type, aStart, aEnd, bStart, bEnd]&lt;/code&gt;), not formatted HTML. Structured clone of a big HTML string is its own bottleneck.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compute intra-line character diffs lazily&lt;/strong&gt;, only for rows currently visible. Users look at a handful of changed lines; computing word-level diffs for all 400 changed rows upfront is wasted work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normalise line endings first.&lt;/strong&gt; Half of all "these files are different but look identical" reports are &lt;code&gt;\r\n&lt;/code&gt; vs &lt;code&gt;\n&lt;/code&gt;. Detect it and say so explicitly instead of showing every line as changed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://devitools.com/file-comparison" rel="noopener noreferrer"&gt;file comparison tool&lt;/a&gt; is where all of that ended up.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. JSON: &lt;code&gt;JSON.parse&lt;/code&gt; is not a validator
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;JSON.parse&lt;/code&gt; tells you &lt;em&gt;that&lt;/em&gt; it failed. It is terrible at telling you &lt;em&gt;where&lt;/em&gt;, and the message differs per engine. V8 now includes a position; older messages don't.&lt;/p&gt;

&lt;p&gt;If you want a usable error you need your own tokenizer, or you extract the position and reconstruct line/column yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;\&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;upto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;upto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;upto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lastIndexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// now you can actually point at it&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also worth knowing: &lt;code&gt;JSON.parse&lt;/code&gt; accepts duplicate keys and keeps the last one. Perfectly valid JSON, and a genuinely common source of "why is my config ignoring this setting". A format/validate tool that doesn't warn about duplicates is hiding real bugs — mine does, in the &lt;a href="https://devitools.com/json-toolkit" rel="noopener noreferrer"&gt;JSON toolkit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;JSON.stringify(obj, null, 2)&lt;/code&gt; is not a formatter for user input: it reorders nothing but it drops comments, loses number formatting (&lt;code&gt;1.0&lt;/code&gt; becomes &lt;code&gt;1&lt;/code&gt;), and throws on &lt;code&gt;BigInt&lt;/code&gt;. For a pretty-printer you want to format the token stream, not round-trip through objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Where I gave up on client-side
&lt;/h2&gt;

&lt;p&gt;Being honest about the limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Usage limits.&lt;/strong&gt; I enforce per-tool daily quotas, and anything enforced in the browser is a suggestion. That lives server-side, keyed by account or IP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Very large files.&lt;/strong&gt; Past a few hundred MB you're fighting memory ceilings that vary by device. I cap and say so rather than letting the tab die.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anything needing a real font/layout engine.&lt;/strong&gt; Faithful document rendering in the browser means shipping a lot of WASM. Sometimes the honest answer is "this one has a server step".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;Client-side-first isn't a purity contest, it's a default. Every file that doesn't get uploaded is a file you don't have to store, secure, or explain in a privacy policy. Most of the time the platform APIs are already enough — the work is in the boring edges: orientation flags, alpha channels, line endings, duplicate keys.&lt;/p&gt;

&lt;p&gt;If you want to poke at the result, the tools live at &lt;a href="https://devitools.com" rel="noopener noreferrer"&gt;devitools.com&lt;/a&gt;. I'm building it a piece at a time and I'd genuinely rather hear what's broken than what's good — the EXIF bug above got found by a user, not by me.&lt;/p&gt;

&lt;p&gt;What's the edge case that cost you the most hours? I'll take suggestions for what to build next.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
