Trim Text
Trim the edges of the whole text, or the edges of each line.
About this tool
Whole-text trim is the trim of the string you pasted. Line trim maps that operation over the lines and joins them again.
Prefix and Suffix is the page that adds characters. This one only removes edge whitespace.
How to use it
- Paste the text.
- Choose whether to trim the whole text or each line.
- Trim. The selected edges are removed.
Limitations
- Whole-text mode removes the edges of the entire paste. Line mode removes the edges of each line and keeps the line breaks.
- The characters removed are the usual whitespace at those edges, not a character you name.
Edges of the paste or edges of each line
Three different cuts
Whole-text mode removes whitespace at the start and end of the entire paste and leaves the middle alone, including blank lines in the middle. Line mode splits on normalized newlines, trims each row, and joins the rows back. Blank-line mode drops rows that are empty after trim, which is a different goal: it is not trimming edges so much as deleting spacer rows. Pick the mode by what you want to keep. Line mode will not remove a blank line that contains only spaces until those spaces are trimmed and the row becomes empty, and even then it keeps the empty row. Use blank-line mode for that.
What counts as an edge
The characters removed are the language’s usual whitespace, not a character you type. You cannot ask this page to strip only underscores or only zeros. A non-breaking space is whitespace in JavaScript’s trim, so it goes. A visible character, including a punctuation mark, stays even if it looks like decoration. Interior double spaces stay in whole-text and line modes. The whitespace remover is the page that collapses interior runs.
Newlines are structure in line mode
Line mode keeps the breaks. It does not join paragraphs. A line that was indented code loses the indent, which is what you want for pasted lists and what you do not want for Python. Whole-text mode is safer for code if the only problem is a blank line before and after the paste. Neither mode is a formatter. Indent size is not normalized to a tab width.
Indentation is data in some files
A Makefile and a Python block use leading spaces as structure. Line mode will strip them because they are edges. That is correct for a pasted list of names and wrong for those files. Whole-text mode leaves the indent alone and only clears the outer edges of the paste. Choose it when the middle of the file must stay byte-for-byte aside from the outer blank margin.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

