Code Diff Formatter
Format code diffs
Loading tool…
How code diffs work
A diff is the answer to a precise question: what is the shortest set of insertions and deletions that turns one text into another? The classic algorithms behind it — Myers' longest common subsequence being the best known — align the two versions line by line and report the rest as changes.
Presentation then decides how useful the answer is. Unified format, familiar from Git and patches, shows one column with plus and minus prefixes and a few lines of surrounding context. Side-by-side shows both versions in parallel columns, which is far easier for reading unfamiliar code. Formatting a diff means taking raw output and rendering it with clear markers, alignment, and structure so that changed regions are obvious rather than buried in punctuation.
Why we built this tool
Developers read diffs constantly — reviewing a pull request, comparing a config against a known-good copy, checking what a deployment changed, or working out why a file behaves differently after an edit.
The code in question is usually proprietary and frequently pre-release. Pasting two versions of a source file into a random comparison site is an unnecessary disclosure of exactly the material a company most wants kept in-house. Our tool computes and renders the diff in your browser, so both versions stay on your machine, nothing is transmitted or logged, and there is no size ceiling. It also works offline, which is handy during an incident on a restricted network.
Tips and common mistakes
- Enable whitespace-insensitive comparison when a reformatting pass is drowning out the real changes.
- Side-by-side reads better for unfamiliar code; inline reads better for reviewing your own edits.
- Compare like with like — diffing a minified file against a formatted one produces noise, not information.
- Strip credentials and customer data before pasting a diff into a ticket.
Open Code Diff Formatter with a link
Code Diff Formatter can be handed its input by the link that opens it, so the page arrives with the work already done. This is meant for assistants and scripts: if a chatbot, an editor extension, or a command-line agent already holds your content, it can build a link instead of asking you to copy and paste into a box.
The payload rides in the fragment — the part of a URL after the #. Browsers never send the fragment to a server, so anything handed over this way stays on your device exactly as a dropped file would. A link that uses the query string instead is rewritten into the fragment by the page before any analytics or ad script can read the address.
Prefix any field with gz — #gza= — to pass it as gzip-compressed base64url, which fits roughly five to ten times more into the same link. Links stay reliable up to about 8,000 characters; past that, chat apps and address bars start truncating them, and the page says so rather than loading half a document.
One exception to the privacy rule: ?url= tells the page to download the input from an address. That request goes from your browser straight to that server — not through ours — but it does leave your device, and it only works if the server allows cross-origin requests.
#a=— the first side to compare#b=— the second side to compare
Example: https://mygadgets.ink/tools/code-diff-formatter/#a=...&b=...
Quick start: using Code Diff Formatter
- Paste the original version into the first input.
- Paste the modified version into the second.
- Run the comparison and choose unified or side-by-side output.
- Read the changed hunks with their surrounding context lines.
- Copy the formatted diff for a review comment or a bug report.
For prose and plain text, Diff Checker is the simpler option; for API payloads, use JSON Diff.