Line-edge guide
How to trim spaces from every line
- Paste multiline text into the input box. The audit counts affected lines and edge characters.
- Select Both Edges, Leading, or Trailing. For code, Markdown, or aligned text, begin with the narrower option because edge whitespace can matter.
- Choose Trim Line Whitespace and confirm that indentation, hard breaks, and alignment still work.
What leading and trailing whitespace means
Leading whitespace appears before the first visible character on a line; trailing whitespace appears after the last visible character and before the line ending. It is easy to miss because the right edge usually draws nothing. This tool checks each line separately instead of trimming only the beginning and end of the entire text block.
Input markers:
[TAB]Indented item[SPACE][SPACE]
[SPACE][SPACE]Second item[TAB]
Trailing-only mode:
[TAB]Indented item
[SPACE][SPACE]Second itemTrimming a text block is not the same as trimming each line
A conventional string trim changes only the outer edges of the complete text block and leaves residue on interior lines. Line-by-line trimming applies the rule separately to every stored line.
This matters for text copied from tables, PDFs, emails, or padded exports. Use the audit to see how many lines will change.
Three modes with different consequences
| Mode | Indentation | Right edge |
|---|---|---|
| Both edges | Removed. | Removed. |
| Leading only | Removed. | Preserved. |
| Trailing only | Preserved. | Removed. |
When trimming is useful
- Cleaning list items copied from an indented document.
- Removing invisible right-edge characters before a text comparison.
- Preparing imported values while retaining their line structure.
- Cleaning trailing whitespace without flattening code indentation.
When whitespace is meaningful
- Python and other indentation-sensitive languages use leading spaces as syntax.
- Markdown can use trailing spaces to request a hard line break.
- Plain-text tables may rely on both leading and trailing padding.
- Preformatted documents may intentionally align content with spaces or tabs.
Which characters are trimmed
The line-edge matcher includes ordinary spaces, tabs, non-breaking spaces, and other Unicode characters recognized as whitespace by JavaScript. It does not include the CR or LF characters that form the line ending. Internal whitespace between visible characters is preserved even when several spaces occur together. If padding keeps reappearing at one edge, read where no-break spaces come from—an editor may be inserting them.
Line endings remain unchanged
Unlike tools that normalize or join lines, this transformation retains the original LF, CRLF, or CR sequence. Only the adjacent horizontal whitespace at the selected edge is removed. The live audit reports affected lines and character totals for both sides, so you can decide whether a trailing-only cleanup is safer than removing indentation.
Worked examples for each trimming mode
Trim both edges for a copied list
If every item has accidental padding on both sides, Both Edges produces clean line starts and ends while leaving spaces between words untouched. Blank lines remain present; use the separate empty-line tool when entire rows should be removed.
Trim leading whitespace only
Leading mode removes indentation from every line but keeps right-edge padding. It can help flatten a plain list copied from a nested document. Do not use it on Python, YAML, outlines, or preformatted text until you have confirmed that indentation is decorative rather than structural.
Trim trailing whitespace only
Trailing mode cleans invisible residue while preserving indentation. It is often the safest option for code comments, imported labels, and version-controlled text. Markdown may interpret two trailing spaces as a hard line break, so review rendered Markdown before accepting the result.
Choose a mode for the destination format
| Content type | Suggested starting mode | What to verify |
|---|---|---|
| Plain lists and copied labels | Both edges | Intentional visual alignment is not required. |
| Source code | Trailing only | Leading indentation remains exactly intact. |
| Markdown | Leading or trailing with care | Nested blocks and hard-break spaces still render correctly. |
| CSV or TSV text | Review before trimming | Only line edges change; spaces inside individual fields are not parsed. |
| Fixed-width reports | Usually preserve | Padding may be responsible for column alignment. |
Frequently asked questions
Does this tool trim every line separately?
Yes. Each LF, CRLF, or CR-delimited line is checked independently. The tool does not trim only the outer edges of the complete text block.
Can I remove trailing spaces without removing indentation?
Yes. Choose Trim Trailing Whitespace. Leading spaces and tabs remain unchanged while whitespace immediately before each line ending is removed.
Are blank lines removed?
No. Their line endings remain. A whitespace-only line may become visually empty after its edge characters are trimmed; use Remove Empty Lines when the whole row should be deleted.
Will the tool change Windows or Unix line endings?
No. CRLF, LF, and CR sequences are preserved as stored. Only whitespace adjacent to the selected line edge is targeted.
Is line trimming safe for Python, Markdown, CSV, or TSV?
Not automatically. Python can require indentation, Markdown can use trailing spaces, and delimited files may contain meaningful padding. Keep the original and validate the transformed text in its destination.
Related cleanup choices
If a document contains whole whitespace-only rows, use Remove Empty Lines. If the problem is U+0009 tabs inside a line, the tab tool can replace, remove, or expand them. If regular and Unicode whitespace should be collapsed throughout a line, return to the main space remover. If the lines themselves should be joined into one block, remove newlines instead of trimming their edges.