textscrubr
Home / Blog / Text tools

How to Remove Tabs and Extra Indentation From Text

Text tools2 min readUpdated 2026-06-24
To remove tabs from text, use find-and-replace to swap tab characters for spaces or nothing, or a cleaner that normalizes whitespace. Be careful with code, where indentation is meaningful. For prose, removing stray tabs and extra indentation tidies the text without changing the content.

Tabs and extra indentation sneak into text from copied documents, spreadsheets, and code. Here is how to remove them cleanly.

Tabs vs spaces

A tab is a single character that renders as a variable-width gap. Text copied from spreadsheets, tables, and some documents is full of them, and they behave differently from spaces, so they cause misalignment when you paste elsewhere.

Method 1: find and replace

In any editor:

Method 2: a cleaner

Paste the text into a cleaner that normalizes whitespace. textscrubr collapses runs of spaces, trims trailing whitespace, and, when you flatten formatting, removes leading indentation, giving you flush, even lines. It also strips the invisible characters and normalizes exotic spaces that copied text usually brings along.

Be careful with code

In code, indentation is meaningful, and in some languages (like Python) it is part of the syntax. Removing tabs or leading spaces from code will break it. If you are cleaning code, either leave the indentation alone or convert tabs to spaces consistently rather than deleting them. A structure-aware cleaner leaves code spacing untouched by default and only tidies prose.

Converting tabs to spaces consistently

If your goal is consistency rather than removal (common in code), most editors have a "convert indentation to spaces" command that replaces tabs with a fixed number of spaces throughout. That keeps the structure while making the whitespace uniform.

Quick recap

For prose, remove stray tabs and extra indentation freely. For code, convert tabs to spaces consistently instead of deleting them, or use a cleaner that leaves code spacing intact.

Scrub this text in one click

textscrubr strips the hidden characters, em dashes, and double spaces, and keeps your lists, headings, and code exactly where you put them. Free, and it runs entirely in your browser.

Clean my text free →

Frequently asked questions

How do I remove tabs from text?

Use find-and-replace to swap the tab character (\t) for a space or nothing, or paste the text into a cleaner that normalizes whitespace. Search ^\s+ to strip leading indentation from every line.

Will removing tabs break my code?

It can. In languages like Python, indentation is part of the syntax. Convert tabs to spaces consistently instead of deleting them, or use a cleaner that leaves code spacing intact.

How do I convert tabs to spaces?

Most editors have a 'convert indentation to spaces' command that replaces each tab with a fixed number of spaces, keeping the structure while making the whitespace uniform.