What Is Convert Tabs/Spaces?
Replace literal tabs with a fixed number of ASCII spaces, or complete runs of spaces with tabs. Choose leading indentation or the entire text. This is character replacement, not alignment to the next visual tab stop, and it does not parse programming-language syntax.
How to Use Convert Tabs/Spaces
- Paste text or load Sample.
- Choose Tabs to Spaces or Spaces to Tabs.
- Choose 2, 4, 6 or 8 spaces per tab.
- Use leading indentation by default; choose Throughout text only if interior spacing should change.
- Review the result, then Copy or Download TXT. Select output manually on Copy failure.
How Convert Tabs/Spaces Works
Leading scope selects the initial run of ASCII spaces and tabs on each physical line. Other characters, including nonbreaking spaces, stop that run. Tabs to Spaces replaces every selected tab with exactly the chosen number of spaces. Spaces to Tabs replaces complete consecutive space groups and leaves the remainder; existing tabs are preserved and do not stop conversion of later leading spaces.
CRLF, LF and CR separators in the input value are retained, including mixed and trailing endings. Browser inputs and clipboard handling may normalize them. Visual tab stops depend on the current position and rendering rules. Replacing a tab with four spaces does not reproduce every editor's four-column tab stop.
Convert Tabs/Spaces Example
Size 4; literal tab notation below is backslash plus t for readability:
| Option | Result |
|---|---|
| Tabs to Spaces, leading | \tA\tB becomes four spaces + A\tB |
| Tabs to Spaces, throughout | A\tB becomes A + four spaces + B |
| Spaces to Tabs, leading | six leading spaces + A becomes \t + two spaces + A |
| Spaces to Tabs, mixed leading | \t + four spaces + A becomes \t\tA |
When to Use Convert Tabs/Spaces
Indentation drafts
Convert a known indentation group while retaining interior text.
Literal tab cleanup
Replace all tabs only when interior delimiters should change.
Format comparisons
Compare fixed groups with the actual editor layout before saving.
Common Mistakes
Conversion is not always reversible: original tabs and matching space groups can become indistinguishable after conversion. Leading scope can still alter indentation inside a multiline string. Throughout text can change string contents, alignment and TSV delimiters. Check the original and your project's formatter rules; this tool does not certify syntax or style compliance.
Input is limited to 1,000,000 UTF-16 units and 20,000 lines. Output cannot exceed 5,000,000 units. Invalid settings or oversized output clear the result and disable export. A download error leaves the selectable output available.
Tips for Better Results
Choose the group size used by your actual file, rather than assuming a programming language has one universal width. For changing physical line separators, use Add/Remove Line Breaks separately and inspect its LF conversion policy.
Share This Tool
End the tabs vs spaces debate: share this free indentation converter with your dev team!