Convert tabs to spaces, or spaces back to tabs, with a configurable number of spaces per tab. This tool is perfect for fixing indentation in code, configuration files, and plain-text documents when moving between editors with different tab settings. All conversion happens instantly in your browser.
The Tabs to Spaces Converter fixes mismatched indentation by converting tab characters into a configurable number of spaces, or converting runs of spaces back into tabs. It's a quick fix for code, configuration files, and plain-text documents that look misaligned after being opened in an editor with different tab settings.
Tabs → Spaces: Every tab character (\t) in the text is replaced with the chosen number of spaces.
Spaces per tab: 4
Input: function() {[TAB]return true;[TAB]}
Output: function() { return true; }
Spaces → Tabs: Every run of exactly N consecutive spaces (where N is the spaces-per-tab setting) is replaced with a single tab character, scanning left to right on each line. Leftover spaces that don't form a full group of N are kept as spaces.
Spaces per tab: 4
Input: " hello" (4 leading spaces)
Output: "[TAB]hello"
Input: " hello" (6 leading spaces, N = 4)
Output: "[TAB] hello" (4 spaces become a tab, 2 spaces remain)
Direction: Choose "Tabs → Spaces" to expand tabs into spaces, or "Spaces → Tabs" to collapse groups of spaces back into tabs.
Spaces per tab: The number of spaces that equal one tab character, from 1 to 16. Common values are 2, 4, and 8.