--- title: "Use the TRIM Function to Clean Up Text and Remove Extra Spaces" slug: "trim-function" description: "Learn to use the TRIM function in Pigment to clean up text by removing leading, trailing, and extra spaces between words." updated: 2025-05-30T09:42:25Z published: 2025-08-22T10:57:28Z canonical: "kb.pigment.com/trim-function" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.pigment.com/llms.txt > Use this file to discover all available pages before exploring further. # TRIM function ## Description Removes all spaces at the beginning or the end of a Text and replaces multiple spaces between words with a single space. You can use the `TRIM` function to remove irregular spacing from texts. ## Syntax `TRIM(Text)` ## Arguments | Argument | Type | Dimensions | Description | | --- | --- | --- | --- | | *Text* (required) | Text | Any Dimensions | Text to remove spaces from. | ## Returns | Type | Dimensions | | --- | --- | | Text | Dimesnions of *Text* | ## Examples | Formula | Result | Description | | --- | --- | --- | | `TRIM(“ text”)` | “text” | Irregular spaces before the text are removed. | | `TRIM(“text “)` | “text” | Irregular spaces after the text are removed. | | `TRIM(“this is a sentence”)` | “this is a sentence” | Irregular spaces between words in the text are replaced with a single space. | | `TRIM(“ this is a longer sentence “)` | “this is a longer sentence” | Irregular spaces before, after and between words are removed or replaced. | ## See also Excel: [TRIM](https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9) Related articles: [TEXT](/v1/docs/text-function) > [!TIP] > More of a hands-on learner? > > Talk to your Customer Success Manager about downloading the Functions and Modifiers in Pigment Application into your workspace. It includes examples of every formula and modifier in Pigment!