guide · text files

Compare two text files on Windows

You have two versions of a text file: a configuration before and after a change, a script from a colleague and your own copy, yesterday’s export and today’s. Where exactly do they differ? Diffoniq shows both files side by side, marks every changed, added and removed line, and highlights the changed characters inside a line.

The short version: press Ctrl+O and enter both files. Changed lines are coloured, and within them the characters that changed are marked. Tab jumps to the next change, Backspace to the previous one. If the files should end up the same, drag the marked lines across to the other side and press Ctrl+S.

1. Open both files

Start Diffoniq and press Ctrl+O. Enter the left and the right file, pick them from the drop-down list of earlier selections, or use the File… buttons to browse. You can also drag two files from File Explorer onto the Diffoniq window, or start Diffoniq with both paths:

"C:\Program Files\Diffoniq\Diffoniq.exe" "D:\config\app.ini" "D:\config\app.ini.new"

That is the installer’s path; the portable version runs from the folder you unpacked it to. If you compare from File Explorer often, switch on Options → Show in Explorer’s Context Menu or Show in Explorer’s “Send to” Menu: select two files, right-click, and Diffoniq opens them. Details in the help: Explorer’s Context Menu and “Send to” Menu.

2. Read the display

The two files stand next to each other, and one screen row always holds matching positions: the line on the left and the line on the right belong together. Where one side has a line the other has not, its counterpart stays blank, so a single inserted line pushes nothing out of step. Four colours carry the meaning:

What you seeMeaning
Plain linesidentical on both sides
A coloured blocka section that differs; the whole block is coloured on both sides, so you see how far a change reaches
Marked characters inside a linethe characters that actually changed (Show Inline Differences, on as delivered)
Lines in the “modified” colourlines you changed in this session, not yet on disk

Horizontal separator lines set the difference sections apart as well, so the structure stays readable in a black-and-white printout. The header above each pane names the file with its size, line count, encoding and line endings; when the two files differ in encoding or line endings, both values are highlighted in amber, because that is a frequent reason a comparison looks entirely different. The status bar counts the changed, added and removed blocks and shows which block the cursor is in. Press F8 for line numbers: each side carries its own numbering, and the two drift apart by exactly the number of inserted or deleted lines.

Text comparison of config_loader-2.3.cpp against config_loader-2.4.cpp: added lines in green, deleted lines in red, a changed line with the changed characters marked, the overview bar on the right; the status bar reads 5 changed, 2 added
Two files side by side. Added, deleted and changed lines in colour; within a changed line, the changed characters are marked. The overview bar beside the scroll bar maps the whole file.

3. Move from change to change

Tab takes you to the next difference, Backspace to the previous one; a beep says there is no further one in that direction. The overview bar at the right edge, next to the scroll bar, shows the whole comparison from the first line to the last and marks every place where the two sides differ, in the colours of the view. One look tells you how many changes there are and where they lie. Click a point of the bar to go there.

Long files are mostly identical. Press F7 (Hide Matching Areas) and the identical passages fold away: what remains is every difference with a few identical lines above and below it for context. Nothing is lost; press F7 again, or double-click a line, to see the files in full around it. Ctrl+G jumps to a line number, Ctrl+F finds text in either file and shows which match you are on and how many there are, F3 repeats the search.

The Find dialog: search text line, Match whole word only and Match case off, Wrap around on, and the counter 3 / 5 next to it
Ctrl+F. Every match is marked in both panes, and the counter says which one you are on and how many there are. F3 repeats the search after the dialog is closed.

4. Decide what counts as a difference

Reformatted code, a file saved with a different tab size, a script from a tool that writes trailing spaces: Options → File Comparison… lets you leave such changes out of the picture. The dialog has four switches: Ignore spaces on comparison (spaces and tabs), Ignore trailing blanks, Expand tabs before comparison with a Tabsize, and Case insensitive compare. As delivered, tabs are expanded and trailing blanks are ignored; spaces inside a line and upper and lower case count. Change a switch and both files are read and compared again. The same dialog sets the number of context lines shown around a change when matching areas are hidden.

The File Comparison Options dialog as delivered: Ignore spaces on comparison off, Ignore trailing blanks on, Expand tabs before comparison on, Case insensitive compare off, Create .BAK backup when saving on, Tabsize 4, Margin Lines 3
Options → File Comparison…, as delivered. Tabs are expanded, trailing blanks are ignored, a .BAK copy is kept when you save; spaces inside a line and case count. Margin Lines is the context kept around a change when matching areas are hidden.

5. Take lines over

Diffoniq is not only a viewer. Mark the lines you want on the other side: click a line, or drag across several, on the side you want to copy from. Then press the mouse button on the marking again and drag it across the separator; the mouse cursor shows where a drop is accepted. Release, and the marked lines replace the lines that face them on the other side. Two things to know: it is a copy, the side you dragged from is unchanged; and the lines land on the corresponding area, not where you released the mouse, so the two sides stay aligned.

The clipboard works too: Ctrl+C copies the marked lines, Ctrl+V replaces a marked area with the clipboard, Del marks lines as deleted. A changed line gets a + next to its number, and an asterisk in front of the file name shows a side with unsaved changes. Nothing is written until you press Ctrl+S; the original is kept with .BAK appended to its name, unless you switch that off in the File Comparison options. Ctrl+Z takes a step back, Ctrl+Y forward.

The side that receives the lines has to be writable; the side you drag from need not be. That is the everyday case when another program hands Diffoniq a temporary copy as a diff viewer: you lift a line out of the old revision into your working file. Details: Merging Changes.

Text comparison of config_loader-2.3.cpp against config_loader-2.4.cpp after one line was taken over from right to left: the line lastError_ = "cannot open " + path_; now sits on the left between lines 19 and 20 with a plus sign instead of a number, and an asterisk stands in front of the left file name in the header; the status bar reads 5 changed, 2 added
One line taken over, not yet saved. The new line on the left carries a + instead of a number, and the asterisk in front of the file name says the side has unsaved changes. Ctrl+S writes it; Ctrl+Z takes it back.

6. Keep or hand over the result

File → Export Report… writes the comparison into one file: a single HTML page with both sides and the colours, plain text with one marker column, or JSON for a program. Mark lines on both sides and press Ctrl+C to paste them into a mail or a ticket as a two-column table with the file names on top. Ctrl+P prints the comparison with the file names in the page header. The same report runs without a window, from a batch file:

"C:\Program Files\Diffoniq\DiffoniqC.exe" /report "D:\config\app.ini" "D:\config\app.ini.new" --out changes.html

The extension of the output file picks the format, and the exit code tells your script whether the files differed. Details: Comparison Reports.

Good to know

Other ways to compare text files

Windows can list the differing lines without extra software. In a command prompt, fc /n "D:\config\app.ini" "D:\config\app.ini.new" prints the lines that differ, with their line numbers. In PowerShell, Compare-Object (Get-Content a.txt) (Get-Content b.txt) lists the lines found in one file only, marked <= and =>. Both give you text to read, not a side-by-side view, and neither takes lines over. Free tools such as WinMerge do; our comparison page shows how they differ from Diffoniq, with the date we checked. If you come from Beyond Compare, see Diffoniq compared with Beyond Compare.

Questions

Does it show which characters changed, not just which lines? Yes. Within a changed line, the characters that differ are marked. The switch is View → Show Inline Differences, on as delivered.

Can I ignore spaces, tabs or upper and lower case? Yes, under Options → File Comparison…: spaces and tabs, trailing blanks, tab expansion and case are separate switches.

Can I make the two files the same? Yes. Drag marked lines across to the other side, or use copy, paste and delete, then press Ctrl+S. Diffoniq takes lines over; for typing new text, use your editor.

The files look completely different, but they are nearly the same. Why? Look at the header above each pane: when the encoding or the line endings differ, both values are shown in amber. Spaces and tabs are the other usual cause; see step 4.

Can I compare two files by right-clicking them in File Explorer? Yes, after you switch on Options → Show in Explorer’s Context Menu or the “Send to” entry. Diffoniq never adds them on its own.

Which Windows versions does it run on? Windows 10 and 11, 64-bit.

Try it on your own two files

Diffoniq runs on Windows 10 and 11, 64-bit. Every feature is available for 30 days before you decide.

Windows and PowerShell are trademarks of Microsoft Corporation. WinMerge and Beyond Compare are trademarks of their respective owners. Diffoniq is not affiliated with any of them.