Compare JavaScript code online

An average function was rewritten as a median function. Paste your own .js files to see their differences the same way. Tips for JavaScript

Original
0 lines
Drop to load into original
Changed
0 lines
Drop to load into changed
−0+0
Original
Changed

About this JavaScript comparison

Reviewing a refactor, checking what a minified bundle changed after a dependency update, or comparing two answers to the same exercise: a JavaScript diff shows which functions, conditions and values moved, without running anything.

Lines are coloured with JavaScript syntax highlighting, so strings, keywords and comments stay readable while the changed parts are marked on top.

What changed in this sample

  • calculateAverage(numbers) was replaced by computeMedian(values).
  • The summing for loop became a sort followed by an even/odd branch.
  • The sample array changed from five numbers to six, so the median takes the even branch.
  • main() was renamed to run(), at the definition and at the call.

Tips for comparing JavaScript

Ignore formatter noise
If one version went through Prettier or ESLint --fix, turn on Ignore whitespace so changed indentation and spacing do not hide the real edits.
Compare TypeScript too
Choose TypeScript in the syntax menu for .ts files; opening a file picks the right one from its extension.
Get a patch for a pull request
Copy as unified diff gives you a standard patch you can paste into a code review comment or apply with git apply.
Focus on the change
Fold unchanged is on by default. Set how many lines of context to keep around each change under More.

How to compare JavaScript online

  1. Paste the older version into Original and the newer one into Changed, or open a file on each side.
  2. Check that the syntax menu says JavaScript, then pick split or unified view.
  3. Step through the changes with the arrows or Alt ↓, and use Settings for options such as ignoring blank lines.
  4. Save the comparison in your browser, share a link, or download it as a .diff, HTML or PDF.

JavaScript comparison: questions

Can I compare minified JavaScript?

Yes, but minified code sits on one long line, so every change looks like the same line. Run both files through a formatter first, then compare, and the differences become readable.

Does the tool run my code?

No. The code is only read and highlighted in your browser. Nothing is executed and nothing is uploaded.

Can I compare JSX or TypeScript?

Yes. Paste it in and choose JavaScript or TypeScript in the syntax menu. The comparison itself works on any text.