Trim Text Online – Remove Leading and Trailing Spaces

Need to clean up messy text? Our free Trim Text Tool helps you trim from left or right, remove leading or trailing spaces, strip out empty lines, or trim each line one by one. Whether you're fixing spacing issues in documents, cleaning copied text, processing code or prepping content for upload—this tool gives you fast, accurate, and flexible text trimming options.

Input Text

Trim Text Options

Output

Examples of Trimmed Text

1. Trim Left Side

Scenario: You want to remove leading spaces or characters from the beginning of each line.

Input:
    Hello world
    Welcome back

Trim Text Option: ✔ Trim Left Side, ✔ Line by Line Trim

Output:
Hello world
Welcome back

2. Trim Right Side

Scenario: You want to remove trailing spaces or characters from the end of each line.

Input:
Hello world    
Welcome back    

Trim Text Option: ✔ Trim Right Side, ✔ Trim Line by Line

Output:
Hello world
Welcome back

3. Remove Empty Lines

Scenario: You want to delete lines that are empty or contain only spaces.

Input:
Hello world

   
Welcome back

Trim Text Option: ✔ Remove Empty Lines

Output:
Hello world
Welcome back


Related Text Tools