Beyond Compare: Ignore Formatting, Whitespace, Tabs and Line Breaks
How whitespace-insensitive comparison works for spaces, tabs, line endings and reflowed lines, what to verify in Beyond Compare, and when to normalize files instead.
When two files differ only in indentation, trailing spaces or line endings, a text comparison can show a wall of changes that hides the few edits that matter. Ignoring whitespace in a comparison filters that noise. This guide explains what that kind of filtering changes, how it differs from actually rewriting the files, and how to tell whether the result will still work where you need it.
What ignoring whitespace actually changes
Ignoring whitespace in a comparison changes how differences are classified and displayed. It does not change the characters stored in either file. A tab is still a tab and a Windows line ending is still a carriage return followed by a line feed. The comparison simply treats those differences as unimportant, or hides them, so the edits you care about stand out.
This is a different kind of transformation from character reversal, visual mirroring or Unicode character substitution, which all produce new characters or a new visual order. Whitespace-insensitive comparison is closer to a display rule: what you see changes, while the underlying data does not.
"Whitespace" covers several distinct cases, and a comparison tool may handle each one separately:
- Leading whitespace: indentation at the start of a line.
- Trailing whitespace: spaces or tabs after the last visible character.
- Embedded whitespace: runs of spaces between words or tokens, such as one space versus three.
- Tabs versus spaces: the same visual indentation stored as different characters.
- Blank lines: empty lines added or removed between content.
- Line-ending characters: CRLF on Windows-style files versus LF on Unix-style files.
- Moved line breaks: the same sentence wrapped at a different point, so the words are split across lines differently.
The last two cases are easy to confuse when searching for how to ignore line breaks or new lines. Line-ending characters are invisible bytes at the end of each line, and a comparison can usually be told to treat CRLF and LF as equivalent. Moved line breaks are structural. A line-based comparison matches line against line, so a paragraph rewrapped at a different width produces different lines even when every word is identical. Ignoring whitespace within lines does not fix that. You need a comparison that works at the word level, or you need to normalize the line structure before comparing, as shown later.
"Formatting" is also ambiguous. In plain text and source code it usually means whitespace and sometimes letter case. In rich documents such as word-processor files, formatting means bold, fonts and styles. If a comparison works on text extracted from a rich document, styling is not part of the text being compared. Whether a particular tool extracts text that way, and which file types it supports, is something to confirm in its documentation rather than assume.
Unicode adds another wrinkle. Non-breaking spaces, thin spaces and zero-width characters look like ordinary spacing, or like nothing, but they are different code points. A rule written for ASCII spaces and tabs may or may not treat them as whitespace. If differences persist that you cannot see, suspect these characters and test with a file that contains them.
Illustrative example, not the output of any specific tool. In the snippet below, a middle dot marks a space, an arrow marks a tab and the CR symbol marks a carriage return. A whitespace-insensitive comparison would ideally report no meaningful change between these two versions, even though their bytes differ on every line:
Version A (LF endings, 4-space indent)
def total(items):
····return sum(items)
Version B (CRLF endings, tab indent, trailing spaces)
def total(items):··␍
→return sum(items)␍
What to check in Beyond Compare
Evidence gap: this article was written without access to Beyond Compare documentation or a test of a specific version, so it does not state exact menu names, option labels or default behavior. Use the checklist below against your installed version and its built-in help. Settings and terminology can vary between versions and file formats.
- Which whitespace categories the settings cover: leading, trailing, embedded, blank lines and line endings may be separate choices.
- Whether "ignored" means hidden or merely de-emphasized. A view that greys out unimportant differences behaves differently from one that removes them from the difference count.
- Whether there is a quick toggle for showing or hiding unimportant differences, separate from the rules that define what counts as unimportant.
- Whether line-ending handling is its own setting rather than part of the whitespace rules.
- Whether the rules depend on the detected file format, for example treating whitespace inside string literals differently from whitespace in code.
- Whether settings apply to the current comparison session only or become defaults for future comparisons.
- How non-ASCII spacing characters are treated, using a small test file if it matters to you.
A quick way to verify any configuration is to create two small files that differ only in the whitespace categories you care about, plus one real word change. With the settings correct, the word change should be the only important difference reported.
Choosing an approach
There are three broad ways to stop whitespace from cluttering a comparison. They differ in whether files are modified and whether the change can be undone.
| Approach | Changes stored characters? | Reversible? | Best for | Main tradeoff |
| Ignore or de-emphasize differences in comparison settings | No | Yes, by changing the setting | Reviewing edits quickly without touching files | Hidden differences still exist and can matter later |
| Normalize copies before comparing | Only in the copies | Yes, originals are untouched | Rewrapped text, mixed line endings, cross-checking results | Extra step, and the copies must not be confused with the originals |
| Normalize the originals, such as reformatting or converting line endings | Yes | Only through backups or version control | Fixing the source of recurring noise across a project | Creates a large whitespace-only change of its own and can break whitespace-sensitive files |
Comparison settings suit day-to-day review, where you want to see what someone changed and the whitespace differences are known to be harmless. Normalizing copies suits cases the comparison settings cannot handle, especially paragraphs rewrapped at a different width, and also gives you an independent check. Normalizing the originals is a project decision. It is usually best done as a separate, whitespace-only change so that later comparisons start clean.
To cross-check a result from the command line, GNU diff provides standard options for whitespace. BSD and other diff implementations differ, so check the help on your system before relying on these flags:
diff -u -b before.txt after.txt # ignore changes in the amount of whitespace
diff -u -w before.txt after.txt # ignore all whitespace within lines
diff -u -B before.txt after.txt # ignore changes that only add or remove blank lines
diff -u --strip-trailing-cr before.txt after.txt # treat CRLF and LF line endings alike
For text that was rewrapped, put every word on its own line in temporary copies. A line-based comparison of those copies then behaves like a word comparison, and the original line breaks no longer matter. The originals are not modified:
# One word per line; any run of spaces, tabs, CRs or newlines becomes a single break
tr -s '[:space:]' '\n' < before.txt > before.words.txt
tr -s '[:space:]' '\n' < after.txt > after.words.txt
diff -u before.words.txt after.words.txt
To normalize copies for a regular line-based comparison, you can convert line endings, strip trailing spaces and tabs, and expand tabs. Expanding tabs assumes a tab width, here 4, so choose the width the files were written for:
# Work on copies so the originals stay untouched
cp before.txt before.norm.txt
cp after.txt after.norm.txt
for f in before.norm.txt after.norm.txt; do
tr -d '\r' < "$f" | sed 's/[[:blank:]]*$//' | expand -t 4 > "$f.tmp" && mv "$f.tmp" "$f"
done
Note that tr -d '\r' removes every carriage return, not only those at line ends. That is usually what you want for line-ending cleanup, but it matters if a file contains deliberate carriage returns elsewhere.
Will the result still work where you need it?
Because ignoring whitespace changes only how differences are displayed, everything the comparison hid is still present in the files. That matters as soon as the text leaves the comparison view.
- Merging and saving: if you copy or merge content while whitespace differences are hidden, check the saved file. Do not assume the hidden differences were resolved in either direction.
- Whitespace-sensitive formats: Python and YAML depend on indentation, Makefile recipe lines require tabs, two trailing spaces in Markdown create a line break, and fixed-width data relies on exact column positions. In these files a whitespace difference can be a real change.
- Line endings: shell scripts saved with CRLF endings can fail on Unix-like systems because the carriage return becomes part of the command. Some Windows tools expect CRLF. Check what the destination requires.
- Copy and paste: some editors, web forms and chat applications convert tabs to spaces, strip trailing whitespace, collapse repeated spaces or change line endings. If exact whitespace matters, transfer the file itself, or paste into the destination and compare again.
- Readability and accessibility: whitespace differences are hard to perceive, both visually and when text is read aloud. Visible-whitespace markers help sighted reviewers. A text report of differences, such as unified diff output, gives a listing that can be read line by line.
- Sensitive input: online diff websites receive whatever you paste, and configuration files often contain passwords, tokens or internal hostnames. Prefer a local application or command-line tool for anything confidential, or redact the content first.
Quick decision checklist
- Only reviewing what changed, and whitespace is known to be harmless: use the comparison's ignore or unimportant-difference settings.
- Paragraphs were rewrapped: compare word-per-line copies or use a word-level comparison, because ignoring whitespace within lines will not help.
- Mixed CRLF and LF endings: treat line endings as equivalent in the comparison, then decide separately whether the files themselves need converting.
- Files are Python, YAML, Makefiles, Markdown or fixed-width data: review whitespace differences rather than hiding them.
- Differences remain that you cannot see: test for non-breaking spaces, zero-width characters and other non-ASCII spacing.
- Confidential content: keep the comparison local.