Code Diff
To compare two code snippets online, paste Original and Changed — or press Load example. The tab runs a line-oriented LCS diff and lists added (green), removed (red), and unchanged lines with line numbers. Copy patch exports a unified diff with --- / +++ headers and @@ hunks (0–10 context); Copy full view exports every +/- line. Nothing is uploaded.
Updated
Paste the original text on the left and the changed text on the right — or press Load example. The tab computes a line-oriented LCS diff and lists added (green), removed (red), and unchanged lines with old/new line numbers. Copy patch exports a unified diff with @@ hunk headers you can choose 0 to 10 context lines for, and Copy full view exports every line with a +/- prefix. Closing the tab clears both panes; nothing is uploaded or written to localStorage.
The algorithm matches whole lines (after normalizing CRLF to LF). It is not Myers/git binary packing, and not a character-level highlight inside a line. The patch format matches what `diff -u` prints, but because the line matcher is simpler than git's, the hunks can be grouped differently from `git diff` on the same files. For huge multi-megabyte dumps, prefer a local CLI diff — this page is for typical snippets and config-sized pastes.
Paste the original (left) text or code. Diff runs in this tab — nothing is uploaded.
Paste the changed (right) text or code. Line-oriented LCS; copy the result as a unified diff patch.
Diff result
Paste original and changed text above, or press Load example. Added lines are green, removed lines are red, unchanged lines stay neutral.
Line-oriented LCS. The patch uses standard --- / +++ headers and @@ hunks, so it can be read by patch or git apply; it is not a binary diff, not a merge tool, and not a remote compare API. Closing the tab clears both panes; nothing is written to localStorage.
How does the Code Diff work?
1. Paste original and changed
Put the older version in Original and the newer version in Changed. Load example fills a small fictional JavaScript sample.
2. Diff locally
The tab runs a line-oriented LCS compare. Nothing is uploaded and no remote compare API is called.
3. Read added / removed / unchanged
Green lines were added, red lines were removed, neutral lines match. Old and new line numbers sit beside each row.
4. Copy the patch or the full view
Copy patch exports a unified diff with --- / +++ headers and @@ hunks; pick 0, 1, 3, 5, or 10 context lines. Copy full view exports every line with a +/- prefix. Closing the tab drops both panes. Need formatting instead? Use JavaScript Formatter or CSS Formatter on this hub.
Questions about Code Diff
- What does this Code Diff tool do?
- It compares an original paste with a changed paste using a line-oriented longest-common-subsequence (LCS) algorithm. You see added, removed, and unchanged lines with old/new numbers, and you can copy a unified diff patch with @@ hunk headers or the full +/- view. Everything runs in your browser — no signup and no upload.
- Does it upload my code?
- No. Diffing is pure in-page JavaScript. There is no account, no server-side compare API, and no file upload. Pastes stay in this tab until you clear them or close the page. We do not write source text to localStorage or send it to a remote diff service.
- Is this the same as git diff?
- Close, but not identical. Copy patch emits the same unified diff format as diff -u and git diff: --- and +++ file headers, then @@ -start,count +start,count @@ hunks with context lines. The line matcher is a simple LCS, so hunks can be grouped differently from git on the same input. It does not add git's diff --git or index lines, does not handle binary files, and does not run three-way merges. For repository history, use git locally.
- Can I apply the copied patch?
- Usually, yes. Save it as a .patch file and run patch -p1 < file.patch against the original, or git apply after renaming the a/original and b/changed headers to your real file path. If the original paste did not end with a newline, the patch does not add the \ No newline at end of file marker, so check the last line after applying.
- Why is there no /code-diff-checker/ or /diff-checker/ second URL?
- One canonical address with a trailing slash: /developer/code-diff/. Queries like "code compare", "file diff", or "code compare online" can land here. We do not publish stub alias slugs that would split the address people and search engines should share, and we do not leave empty checker URLs that 404.
- Does it highlight character changes inside a line?
- v1 is line-oriented: if any character on a line changes, the whole line is treated as removed on the left and added on the right. Intra-line character highlighting may ship later without a second URL. Whitespace-only changes still count as different lines.
- How is this different from JavaScript Formatter on this hub?
- JavaScript Formatter pretty-prints or minifies one JavaScript paste. Code Diff compares two pastes and shows what changed. They share the same privacy rule (local only) but solve different jobs — this page does not format JS, and JavaScript Formatter does not diff two versions.
- Can it handle very large files?
- The page is meant for typical snippets and config-sized pastes. Multi-megabyte dumps can strain browser memory because the LCS table grows with line counts. There is no upload size limit, because nothing is uploaded — the limit is your browser's memory and responsiveness. For huge files, prefer a local CLI diff.
- Is anything stored in localStorage?
- No. Original and changed text live in React state for this tab only. Closing the tab clears them, and we do not mirror pastes into localStorage or cookies. Hosting logs may show that you requested the page URL, not the code you typed.
What else can I open?
- JWT Token DecryptDecrypt a compact JWE locally with Web Crypto.
- Flexbox GeneratorBuild a CSS flexbox layout visually with a live preview, then copy the CSS or Tailwind classes.
- CSR DecoderDecode PKCS#10 CSRs in the browser — subject, SANs, public key, attributes, and SHA-256/SHA-1 fingerprints.
- Certificate DecoderDecode SSL/X.509 PEM certificates in the browser — expiry, SANs, issuer, fingerprints.
- JWT Token GeneratorCreate and sign a compact HS256 JWT locally in the browser.
- Timestamp to DateConvert Unix timestamps to UTC and local dates in the browser.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.