On-device AI — professional-grade, fully private.

Whitespace Trimming Tool

Trim whitespace from any text file — nothing is uploaded.

  • Runs on your device
  • Keeps your line endings and BOM
  • One file free · 20 at once with Pro
  • Reads UTF-8, UTF-16 and Windows-1252

Drop a text file here

or paste below · .txt .md .csv .log .json .xml .yaml .sql and more

Pro
0 characters
Presets
Trim each line
Blank lines
Spacing
Tabs and spaces
Invisible characters
Output
Line endings
Final newline
Save as
Add text or a file to start.

How to trim text

  1. 1

    Add your text

    Paste into the box, or drop a file. Plain text, Markdown, CSV, logs, JSON, XML, YAML, config and source files are all accepted.

  2. 2

    Choose what to clean

    Start with a preset, or switch on exactly what you need: trim the ends of each line, remove blank lines, convert tabs, or strip invisible characters.

  3. 3

    Check the result

    The preview updates as you change settings, and the counters tell you how much whitespace was removed and how many lines changed.

  4. 4

    Copy or download

    Copy the cleaned text, or download it in the encoding it arrived in. Nothing is ever sent anywhere.

What each control does

Every option below is independent, and they always run in the same order, so the same settings on the same text give you the same result every time. Start from a preset if you would rather not think about it.

Trimming the ends of a line

Trim the start removes spaces and tabs before the first visible character on a line; Trim the end removes them after the last one. Both are on by default, because that is what people mean by trimming. Keep indentation changes what Trim the start does on lines that have content — the indent is left exactly as it is, while lines holding nothing but whitespace still collapse to empty. That combination is what an editor means by 'trim trailing whitespace' and it is the safe setting for source code.

Blank lines

Remove blank lines deletes every line with nothing visible on it. Limit consecutive blank lines keeps your paragraph breaks but caps how many blanks may sit together — set it to one for a single gap between paragraphs, or zero to remove them all. Use one or the other; together, the limit has nothing left to act on.

Spaces, tabs and indentation

Collapse repeated spaces reduces runs of whitespace inside a line to a single space, leaving the ends to the trim options. Tabs and spaces converts in either direction: tabs become the number of spaces you choose, or leading spaces are folded back into tabs. The two directions are exact inverses, so a file can be converted and converted back without drift. Collapse everything to one line is the aggressive option — it turns the entire document into a single line and is meant for turning a wrapped paragraph back into one field value.

Characters you cannot see

Normalise Unicode spaces replaces non-breaking spaces, ideographic spaces and the whole family of typographic spaces with an ordinary one. Remove zero-width characters deletes the zero-width space and the word joiner. It deliberately leaves the zero-width non-joiner and zero-width joiner alone: those are required by Persian, Urdu and several Indic scripts, and they are what holds a multi-person emoji together — a cleanup that quietly rewrites Persian words and splits a family emoji into three people is worse than no cleanup at all.

Line endings and the final newline

Line endings are kept exactly as they arrived unless you change this control, right down to a file that mixes CRLF and LF line by line. Final newline is the other half of the same question: many tools, and every code review, expect a text file to end with exactly one newline, and some expect none at all.

Why trim text

Stray whitespace is invisible and consequential. It is the reason a spreadsheet lookup returns nothing, an import creates a duplicate customer, a diff shows twenty changed lines when one line changed, and a form rejects an email address that looks perfectly correct.

  • Spreadsheet and database imports — a trailing space makes two identical-looking values into two different keys.
  • Pasted content — text out of Word, a PDF or a web page arrives padded, double-spaced and full of characters that are not the ones they appear to be.
  • Cleaner diffs — trailing whitespace is the single most common cause of a review full of changes nobody made.
  • Logs and exports — aligned columns and blank separator rows are for reading, not for parsing.
  • Form and API input — a leading space in a key or a token is the classic cause of an authentication failure that makes no sense.

The characters that break things silently

Ordinary spaces are the easy half. The whitespace that causes real trouble is the whitespace that does not look like whitespace, and no amount of staring at the screen will find it.

  • Non-breaking space (U+00A0) — what a word processor inserts to stop a line breaking in the wrong place. It is not the same character as a space, so a comparison fails and a search finds nothing.
  • Zero-width space (U+200B) — genuinely invisible. Copied out of web pages constantly, and it survives every trimmer that only looks for ordinary spaces.
  • Ideographic space (U+3000) — the full-width space used in Chinese, Japanese and Korean text. Common in CJK exports and never handled by tools written against ASCII.
  • Byte-order mark (U+FEFF) — belongs at the very start of a file as an encoding marker, and anywhere else is a stray. Most whitespace tools quietly delete it from the front of your CSV — which is exactly the copy Excel needed.
  • Next line (U+0085) — whitespace by the Unicode standard, and not by the definition most software uses, so it survives a trim that removes everything around it.

File types and text encodings

A trimmer that assumes every file is UTF-8 does not fail loudly on one that is not — it produces a tidy, confident, completely wrong result. A UTF-16 log read as UTF-8 becomes alternating characters and null bytes; trim that and you have destroyed the file while the tool reports success.

Which files it opens

Plain text and Markdown, CSV and TSV, log files, SRT and VTT subtitles, JSON, XML and HTML, YAML, INI and other config formats, SQL, and around twenty source-code extensions. The list is deliberately closed: a file that is not on it is refused at the moment you choose it, rather than accepted and then failed halfway through. A Word document, PDF, spreadsheet or slide deck is refused with a direct link to the tool that pulls the text out of it.

Which encodings it reads

UTF-8, UTF-8 with a byte-order mark, UTF-16 in either byte order, and Windows-1252 — which is what a legacy export from a Windows application usually is, and where smart quotes, em dashes and the euro sign live. The encoding is detected from the file, and the result is written back in the same one, so a UTF-8 CSV that Excel opens correctly still opens correctly afterwards. UTF-32, and UTF-16 with no byte-order mark, are refused by name rather than guessed at: getting the byte order wrong produces plausible-looking nonsense rather than an error.

Trimming code, YAML and config safely

Whitespace carries meaning in more formats than people expect, and the damage is not always visible in the result. These are the settings to reach for when it does.

  • Turn on Keep indentation — before trimming anything indented. Trailing whitespace still goes; the indent that Python, YAML and Markdown depend on stays.
  • Set Final newline to exactly one — which is what POSIX expects of a text file and what stops a version-control diff marking your last line as changed.
  • Never use Collapse everything to one line — on a structured format. It is for prose that needs to become one field, not for anything a parser will read.
  • Be careful inside quoted strings — trimming operates on lines, not on syntax, so trailing spaces inside a quoted CSV field or a multi-line string are removed along with the rest.
  • Check Markdown — two trailing spaces at the end of a line are a hard line break in Markdown. Trimming the ends of lines removes them, which is usually what you want and occasionally is not.

Batch trimming and file limits

One file or one paste is free, with every cleaning option available — nothing about the trimming itself is held back for a paid plan. What Pro buys is scale.

What Free includes

One file or paste at a time, up to 10 MB, and every option on this page. If a file is over the cap, the message says so before anything starts and points at the text splitter, which breaks one oversized export into pieces that each trim — a free route, not an upsell. A Free user never reaches a progress bar that then fails.

What Pro adds

Up to 20 files queued at once with one press, downloaded as a single archive rather than 20 separate save prompts, and a size limit set by your device rather than by us. This is the part no comparable tool offers at all: every online whitespace remover we compared handles exactly one paste at a time.

When to use it

The trimmer earns its keep wherever text has been moved between two systems that disagree about whitespace.

  • Before an import — clean a CSV or a column of pasted values so the keys match on the other side.
  • After copying out of a document — a paste from Word or a PDF is the single most common source of invisible characters.
  • Tidying logs — drop the blank separator lines and the alignment padding before anything has to parse them.
  • Preparing a commit — trailing whitespace removed and one final newline, without opening an editor.
  • Moving between Windows and Linux — normalise line endings once instead of arguing with a diff.
  • Cleaning subtitle files — SRT and VTT survive a trim intact, and their stray trailing spaces do not.

When not to trim

There are formats where whitespace is data, and a trimmer is the wrong tool for them.

  • Fixed-width data files, where the column positions are the format and trimming destroys them.
  • Anything where trailing spaces are meaningful content rather than accidental padding — some test fixtures and diff-based formats are like this on purpose.
  • Poetry, ASCII art, or any layout where the shape on the page is the point.
  • Documents where only a database or an application should normalise a field, because it has rules this tool cannot know.
  • A file you have no copy of. Trimming is not reversible, so keep the original until you have checked the result.

Limitations and compatibility

It works on plain text only, so formatting from a word processor or a web page is not preserved — it was never in the text to begin with. Trimming operates line by line and does not understand syntax, so it cannot tell a trailing space inside a quoted string from one after it. UTF-32 files, and UTF-16 files with no byte-order mark, are refused rather than guessed at. Everything runs on your device, in any current browser, and keeps working with no network once the page has loaded.

A 10 MB log file trims in about a twentieth of a second, and the page stays responsive the whole time because the work never happens on the thread that draws the screen.

Frequently asked questions

How does the text trimmer work?

Paste text or open a file, then switch on what you want cleaned: trim the start or end of each line, remove blank lines, limit how many blank lines can sit together, collapse repeated spaces, convert tabs, or strip invisible characters. The preview updates as you change settings, and counters show how much whitespace was removed and how many lines changed. Copy or download the result when it looks right.

Is my text private and secure?

Yes. Your text is never sent anywhere — the whole trim runs on your device, and there is no upload step and no copy on a server. That also means it keeps working with no network once the page has loaded, and there is no file size a server would refuse: the only ceiling is your own device.

Will trimming change my line endings?

Not unless you ask it to. Line endings are kept exactly as they arrived — a CRLF file stays CRLF, and a file with a mix of both keeps the mix line by line. If you do want them made consistent, the Line endings control converts everything to LF or CRLF in one step. This is worth checking on any tool: trimming the end of a line and stripping the carriage return with it is an easy mistake to make and a hard one to spot.

What does collapse to one line do?

It replaces every run of whitespace, line breaks included, with a single space and trims the ends, producing one dense line. Paragraph and line structure is not preserved, so use the per-line options instead when you need to keep separate lines. It is the right choice for turning a wrapped paragraph back into a single field value.

How do I remove blank lines?

Remove blank lines drops every line that is empty or holds only spaces and tabs. If you would rather keep your paragraph breaks, use Limit blank lines instead and set how many consecutive blanks may remain — one keeps a single gap between paragraphs and removes the rest. The two can be used together, but usually only one of them is what you meant.

Is it safe for code and indented text?

Switch on Keep indentation before trimming. Indentation on lines with real content is then left exactly as it is, while trailing whitespace is still removed and whitespace-only lines still become empty — which is what an editor's 'trim trailing whitespace' does, and what a code review expects. Convert tabs handles tab and space indentation in either direction. Always review the result on anything where whitespace carries meaning.

What are zero-width and non-breaking characters, and why do they matter?

They are characters you cannot see but that software still counts. Text copied out of Word, a PDF or a web page routinely carries non-breaking spaces instead of ordinary ones, and zero-width spaces between words. A spreadsheet import then fails to match, a lookup returns nothing, and the text looks perfectly normal on screen. Normalise Unicode spaces converts them to plain spaces, and Remove zero-width characters deletes the invisible ones — leaving the joiners that Persian, Arabic, Indic scripts and emoji sequences actually need.

What is a BOM, and should I remove it?

A byte-order mark is an invisible marker at the very start of a file that tells software which encoding it is in. Excel needs it to open a UTF-8 CSV without mangling accents; many command-line tools and JSON parsers choke on it. This tool keeps it by default, because it belongs to the file rather than to your text, and gives you a Strip BOM control for when you know you want it gone.

Which files and encodings can it open?

Plain text, Markdown, CSV and TSV, logs, subtitles, JSON, XML, HTML, YAML, INI and config files, SQL, and around twenty source-code extensions. It reads UTF-8, UTF-8 with a byte-order mark, UTF-16 in either byte order, and Windows-1252, and writes the result back in the same encoding so nothing is mangled downstream. A Word document, PDF or spreadsheet is refused with a link to the tool that extracts its text instead.

Is it free, and can I trim several files at once?

It is free for one file or paste at a time, up to 10 MB, with every cleaning option available — nothing is held back. Pro raises the size to whatever your device can handle and lets you queue up to 20 files and download them as a single ZIP, which is the part that turns a folder of exported logs from an afternoon into one press.

4.6out of 5

from 160 ratings

Rate this tool

Tap a star — it takes a second