About
Transform tabs into spaces for the purpose of formatting. This tool proves beneficial when dealing with text or code that uses tab-based indentation, reducing its horizontal space footprint. You have the flexibility to determine the number of spaces equivalent to a single tab.
Leading Tabs
Exclusive handling of leading tabs. With this option enabled, the tool exclusively converts tabs that are not preceded by another character or string (as illustrated in the examples). When disabled, all tabs are replaced with spaces, regardless of their placement.
Basic Examples
Input
[tab]
Example 1: Replacement with 4 spaces. Leading tabs enabled.
[4 spaces]
In the first example above, the tab between the words "Hello" and "World" is ignored because the tab is preceded by the letter 'o'.
Example 2: Replacement with 1 space. Leading tabs disabled.
[space]
Notes
- In the bottom left corner, you can monitor the count of tabs that have been replaced.
- You can also use a tab within the text box.
Related Tools
- Spaces to Tabs - Convert spaces back to tabs.
Replace tab characters with a chosen number of spaces. Make indentation explicit when sharing plain text between editors.
How to use
Set the replacement count and choose all tabs or the leading tab option. Apply and inspect any remaining tabs.
Example
With four spaces per tab, one tab before Hello becomes four ordinary spaces.
FAQ
Does it match tab stop alignment?
No. It inserts a fixed number per matched tab rather than calculating cursor position. Leading mode currently replaces only the first tab of each line per pass.
A practical task
Decide if the task needs a fixed replacement or alignment to tab stops. This tool inserts a fixed number of spaces. Compare a sample containing an internal tab and several leading tabs so the chosen mode's boundaries are clear.
Another useful question
Why are leading tabs left after one pass?
The leading option replaces the first tab of each line in the current implementation. Inspect repeated indentation and repeat only if that is the intended transformation.
Details for interpreting the result
| Detail | Explanation |
|---|---|
| Whitespace characters | An ordinary space, a tab, a nonbreaking space, and a zero width space are different characters. They can look similar or invisible. Choose the exact kind of cleanup instead of treating all blank looking input as equivalent. |
| Tabs and positions | A tab character usually moves to a tab stop in an editor. Replacing it with a fixed number of spaces is a different operation. The visible distance depends on the editor's tab width and the current position. |
| Trimming and content | Trimming removes characters from an edge rather than the middle. Whole text trimming differs from trimming every line. Preserve indentation in code or structured text when it carries meaning. |