Trim Text

Remove leading and trailing whitespace from the whole string or from every line.

What Trim Text helps you do

Remove leading and trailing whitespace from a whole string or from every line. Whitespace that looks invisible in an editor often breaks comparisons and imports, so trimming is a common cleanup step. The tool offers four modes so you can trim both ends, only the start, only the end, or each line independently.

Text is trimmed locally in your browser and is not uploaded to Haivix.

How it works

Each cleanup tool applies one deterministic string transformation to the pasted text inside the page. There is no parser, model or server call: the same input and options produce the same output every time. The browser holds the text in memory, so the result updates as you edit and is not retained after the tab closes. Because the transformation is literal, non-breaking spaces, mixed line endings and tabs may behave differently from a word processor; compare a short sample before applying it to a large file. The page never rewrites the source on disk, so the only undo is your own copy.

How to use Trim Text

  1. Paste the text and choose whether to trim the whole string or each line.
  2. Run the trim to strip the outer spaces and tabs.
  3. Check that internal spacing was not changed.
  4. Copy the cleaned-up text.

When to use it

  • Clean values copied from a spreadsheet where cells carry trailing spaces.
  • Strip indentation from a block of code before pasting it elsewhere.
  • Fix comparison failures caused by invisible leading whitespace.
  • Normalize a list of names before matching them.
  • Remove a trailing newline from a value copied out of a file.
  • Clean each line of a pasted data dump.

When not to use it

  • Do not use it to collapse spaces inside a line; use the extra-spaces tool.
  • Do not use it to remove line breaks; use the line-break tool.
  • Do not use it when indentation is meaningful and must be preserved.

Example

A line of three spaces then text then two spaces becomes just the text once trimmed. In each-line mode, a whole block loses its leading indentation but keeps its line breaks. In both-ends mode, only the very start and end of the whole block are affected.

What you can do with Trim Text

  • Trim both ends of the whole text.
  • Trim only the start or only the end.
  • Trim every line independently.
  • Remove spaces, tabs and newlines at the edges.
  • Copy the cleaned text in one action.
  • Run the trim locally with no upload.

Example: verify the cleanup on a sample

Paste a short, representative sample first rather than the whole file. Check the edges: leading and trailing spaces, blank lines, tabs and any non-breaking spaces the source may contain.

Apply the transformation and compare the sample with the original. If the change is correct, run the full text; if not, adjust the source or choose a different cleanup tool.

Copy or download the result and keep the original until the destination import succeeds. Most of these tools are one-way, so the source file is the only reliable undo.

If the text came from a PDF, a spreadsheet or a CMS, look for invisible characters before blaming the cleanup. A no-break space or a soft hyphen can survive the pass and still break a comparison downstream.

Run the cleaned text through the destination's preview or import step before deleting anything. A formatting change that looks right in the textarea can still fail a strict parser.

What to know before you start

  • Trimming removes spaces, tabs and newlines at the edges only, not internal runs.
  • Non-breaking spaces and other Unicode blanks may not always be treated as whitespace by every runtime.
  • Each-line mode removes indentation, which is destructive for code.
  • There is no preview of which characters were removed.

Common mistakes

  • Choosing both-ends mode when every line needed trimming.
  • Using each-line mode on code that relies on indentation.
  • Expecting internal runs of spaces to shrink; trimming only touches the edges.
  • Assuming a non-breaking space is always trimmed.
  • Trimming a value that intentionally starts with a space.

Troubleshooting

If a space remains at the edge, it may be a non-breaking space or another character outside the runtime's trim set.

If line breaks disappear, both-ends mode removed them at the very edges; use each-line mode instead.

If indentation is gone, each-line mode was used on code.

If the result is unchanged, the text had no edge whitespace.

Related standards and documentation

  • Unicode whitespace includes characters such as the no-break space that may not look like a space.
  • Line endings may be CRLF, LF or CR before cleanup; normalize them first when the target requires one style.
  • The tools operate on Unicode text, not on bytes in a legacy encoding.
One transformation, checked on a sample
  • Compare a short sample first.
  • Watch for non-breaking spaces and tabs.
  • Keep the original until the import works.

Frequently Asked Questions