TRIM() function can be used to trim spaces from both ends of a given string. It is used to fix irregular spacing in Excel.