Browsers & softwarePractical guides

Text diff says unchanged after ignoring spaces? Check spaces inside string values

Ignoring spaces can classify two different field values as an unchanged line. First compare characters with spaces included, then decide whether to filter formatting changes. This example changes one space inside a JSON string while keeping the quantity fixed.

Two laptops and a phone arranged on a desk
Illustrative photo: Gavin Tang · Unsplash License

Key Takeaways

Compare with spaces included before reviewing field values. KitNelo’s ignore option removes ordinary spaces and tabs when comparing lines. It can classify this example as unchanged while retaining both original texts for inspection.

In this article

Locate the change with a one-space example

The JSON standard treats strings as values. The space in label below belongs to its content. Paste the two lines into the text comparison tool, choose character precision and leave the ignore-spaces option off. Check the removed space between A and B.

Original text

{"label":"A B","qty":12}
Fictional label and quantity.

Comparison text

{"label":"AB","qty":12}
The quantity stays fixed; the label value changes.

Identify the selected comparison rule

The current ignore option removes ordinary spaces and tabs for the line comparison. Enabling it can label this example unchanged; the original left and right strings remain in the result. Turn it off and parse or inspect the fields when deciding whether their values match.

The tool normalizes CRLF and CR to LF before comparison. Keep and examine original files separately when the task concerns exact bytes or line endings. JsDiff’s documentation describes its comparison operations. Confirm another application’s whitespace rules before interpreting its output.

Review the view and the saved evidence

Use the configuration meaning check when formatting code. For a shared workflow, the revision handoff helps record who reviewed the actual change.

  1. Start with character precision and all differences visible. Check both source texts on the changed row.
  2. Hide unchanged rows when navigating the review, using previous and next change. Keep the complete input alongside the filtered view.
  3. Export JSON and confirm its original text, precision and ignore setting match this run. Record what the label change means for the receiving workflow.

Further reading & sources

Put the guide into practice

Open the relevant tool, preview the result and check your exported file.