Skip to content
UniKit

Text trim

Clean up messy text in one pass: trim line edges, collapse repeated spaces, drop or merge blank lines, unify CRLF/LF/CR, strip the BOM and zero-width characters, convert ideographic spaces and cut chosen characters off both edges.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Text to clean

Cleanup options

Line breaks
Invisible characters

Cleaned output

The result uses the selected line break and can be pasted straight back into a file.

Paste text to see the cleaned result instantly.

What this tool does

  • Text copied from Excel, a PDF or a web page usually arrives with stray spaces and extra blank lines — clean it before pasting it into code or a spreadsheet.
  • Convert CRLF text exported from Windows into LF so Git stops showing whole-file diffs.
  • Remove the invisible BOM and zero-width characters that break JSON parsing and make string comparisons fail.
  • Strip marker characters from line edges in bulk, turning - item - into item.

Example

Input

  hello   world  


  foo  

Output

hello   world

foo

By default the edges are trimmed, CRLF becomes LF and consecutive blank lines collapse into one. Enable “Collapse repeated spaces” as well and hello world becomes hello world.

Frequently asked questions

What is the difference between removing and merging blank lines?

Removing deletes every blank line, so paragraph gaps disappear too. Merging only compresses runs of consecutive blank lines into one, keeping a single gap between paragraphs. Merging is on by default; enable removing when you want them gone entirely.

What are the BOM and zero-width characters, and why remove them?

The BOM is U+FEFF at the start of a file — Notepad adds it when saving UTF-8 and it makes JSON.parse fail while adding an invisible character to the first line. Zero-width characters (U+200B/200C/200D) usually come from web pages; they are invisible but break string comparisons and searches. Both are cleaned by default.

Which line break should I choose?

LF is the convention on Linux and macOS and in Git; CRLF is required by Windows Notepad and some protocols such as HTTP and email; CR is the classic Mac style. “Keep as is” reuses whichever style appears most often in the input.

When would I use “trim trailing whitespace only”?

When the leading indentation matters — Python, YAML, Makefiles — but trailing spaces are meaningless and often trigger lint errors. Turn off “Trim line edges”, turn on the trailing-only option, and only the ends of lines are cleaned.

Does stripping characters remove them from the middle of a line?

No. The characters are removed only where they appear consecutively at the start or the end of a line. Stripping - from - item - gives item, while the dash inside a-b is untouched.

Keywords:trim textremove whitespaceremove blank linesremove line breaksstrip bomzero width characters文本清理去除空格删除空行统一换行符去 BOM零宽字符

Related tools