# Trim - script and chart function

Trim() returns the input string trimmed of any leading and trailing spaces.

Syntax:

Trim(text)

Return data type: string

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Trim.htm)

#### Examples and results:

Example: Chart expression

| Example | Result |
| --- | --- |
| `Trim( ' abc' )` | Returns 'abc' |
| `Trim( 'abc ' )` | Returns 'abc' |
| `Trim( ' abc ' )` | Returns 'abc' |

Example: Load script

```
Set verbatim=1; 
					
T1:
Load *, len(TrimString) as TrimStringLength;          
Load *, trim(String) as TrimString;
Load *, len(String) as StringLength;               
Load * inline [
String
'   abc    '
' def  '](delimiter is '\t');  
				
```

Information noteThe "Set verbatim=1" statement is included in the example to ensure that the spaces are not automatically trimmed before the demonstration of the trim function. See [Verbatim](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemVariables/Verbatim.htm) for more information.

Result:

| String | StringLength | TrimStringLength |
| --- | --- | --- |
| def | 6 | 3 |
| abc | 10 | 3 |