Hidden WordScanner
Private scans · No account required

How to Remove Extra Spaces and Tabs From Data

Extra spaces are the most common reason two values that look the same do not match.

Short answer

What you need to know

Trim spaces and tabs from the start and end of every value, turn runs of two or more spaces inside a value into one, replace tabs inside values with a space, and replace no-break and other unusual spaces with a normal space. In a CSV, change only the values, never the separators, and review the changes before saving.

Where extra spaces come from

Spreadsheets keep a space typed after a name. Forms let people paste text with a space at the end. Web pages and word processors use no-break spaces to keep words together, and those come along when the text is copied. Exports from other systems pad values with spaces to a fixed width.

None of them is visible in a spreadsheet cell, which is why they survive until an exact comparison fails.

Which spaces to remove and which to keep

Spaces at the start or end of a value are almost never wanted, and removing them is the safe first step. A run of spaces in the middle of a name or address is usually a typing slip and can become one space.

A tab inside a value usually came from copying out of a table. Replace it with a space, unless the file is tab-separated, where tabs are the column breaks themselves; Data Check does not count those.

A no-break space looks like a space but is a different character, so a search for "New York" does not find New York written with one. Replacing it with a normal space keeps the words apart and makes them match. Keep spaces that are part of the data's format, such as fixed-width codes, and limit the cleaning to the columns that need it.

A worked example

A column of product codes holds "AB-100", " AB-100", and "AB-100 ". A database counts three different codes. Data Check reports one leading space and one trailing tab in the code column.

Choosing Remove for spaces at the start or end makes all three AB-100. The preview lists each change as ·AB-100 → AB-100 and AB-100→ → AB-100, where · is a space and → is a tab, so you can see exactly what goes before you download.

Doing it in a spreadsheet instead

Excel and Google Sheets have a TRIM function that removes spaces at the ends and turns runs of spaces into one. It works on ordinary spaces only: it leaves no-break spaces and tabs in place, and the formula results then have to be pasted back as values.

For a whole file, cleaning the values directly and reviewing a before-and-after list is quicker and catches the characters TRIM misses.

Important limitation

Verify important findings

Some data depends on its spacing, such as fixed-width codes, poetry, or values compared with an external system that kept the spaces. Check with whoever uses the data before trimming a column that may be one of those.

Remove spaces and tabs with Data Check Review the methodology

Further reading

Authoritative references

These primary sources support the concepts and reference information in this guide. Their inclusion does not imply endorsement of Hidden Word Scanner.