Compare Code Line by Line

Paste or upload two code files to compare them line by line

Original Code

1
Lines: 0 Characters: 0

Changed Code

1
Lines: 0 Characters: 0
+0 added −0 removed 0 unchanged
Quick answer

Select a language from the dropdown, paste your original code in the left panel and the changed version in the right panel, then click Find Differences. Added lines appear in green, removed in red, with line numbers. Upload files directly using the upload icon on each panel. Nothing is sent to a server.

How to use this tool

Select the language from the dropdown at the top (this filters the file upload dialog and loads language-appropriate samples). Paste or upload your original code on the left and the changed version on the right. Click "Find Differences." The diff output shows every changed line color-coded with line numbers.

Toggle between Unified view (single column, same format as Git) and Side-by-Side view (two parallel columns). The Copy Diff button copies the full diff as plain text. The Sample button loads a language-specific example based on your selected language.

Supported languages

The comparison engine works on any text-based language - it does not parse or interpret code syntax, so it handles any file that stores content as plain text. The language selector controls:

  • The file upload filter (which file extensions are shown in the browser's file picker)
  • The sample code loaded when you click the Sample button
LanguageFile extensionsSpecific tool
Python.py, .pyw, .pyx, .ipynbCompare Python
JavaScript / TypeScript.js, .ts, .jsx, .tsx, .mjs, .cjsCompare JavaScript
CSS / SCSS.css, .scss, .sass, .lessCompare CSS
HTML.html, .htm, .xhtml, .svgCompare HTML
Any language.json, .xml, .yaml, .sql, .go, .java, .php, .rb, .rs, .c, .cpp, .sh, .md, and moreThis page

Use cases

Pre-merge code review

Compare your working copy against the original to catch unintended changes, missing lines, or accidentally introduced bugs before submitting a pull request. Works without a repository - just paste or upload the two file versions.

Reviewing AI-generated code

When an AI assistant rewrites a function, paste the original and the AI output side by side to see exactly what changed. This is faster than reading both versions in full and more reliable than trusting the AI's change summary.

Configuration file auditing

Compare two versions of a configuration file (nginx, Docker Compose, Kubernetes YAML, GitHub Actions) to catch unintended changes between environments or deployments.

Tracking incremental rewrites

When refactoring a module incrementally, compare the before and after to confirm no logic was accidentally removed or altered during the structural changes.

How the diff algorithm works

The comparison uses a Longest Common Subsequence (LCS) algorithm. Both code inputs are split into lines. The algorithm builds a matrix that tracks the longest sequence of lines that appear in both versions in the same order. Lines in this common sequence are "unchanged"; lines outside it are "added" or "removed." This is the same principle used by the Unix diff command and Git. The algorithm compares lines as strings - it does not understand language semantics, so a one-space indentation change will show as a changed line.

FAQs

Can I compare minified code?

Yes, but minified files are a single very long line, so the diff will typically show the entire minified output as one changed line. For meaningful diffs, compare non-minified (development) versions of your files.

Is indentation compared?

Yes. The tool compares lines as exact strings. A line with two spaces of indentation and a line with four spaces will be shown as different even if the content is otherwise identical. For Python or YAML where indentation is significant, this is usually the correct behavior.

Does this work with Jupyter notebooks?

You can upload .ipynb files - they are JSON. The diff will compare the raw JSON structure, which includes cell content, metadata, and outputs. For a cleaner diff, export the notebook to .py first.

Is my code private?

Yes. All processing runs in your browser. No code is sent to any server at any point.