About Spaces ↔ Tabs
Converts leading whitespace on each line — useful for switching between space-indented and tab-indented code. The tab size setting controls how many spaces equal one tab when converting. Runs entirely in your browser.
Converts leading whitespace on each line — useful for switching between space-indented and tab-indented code. The tab size setting controls how many spaces equal one tab when converting. Runs entirely in your browser.
The tabs-vs-spaces argument may never end, but converting between them shouldn't require an editor plugin. This tool expands tabs to N spaces or compresses leading runs of N spaces back to a single tab, where N is the tab width you choose (1–8). Only the leading indentation of each line is touched — strings, comments, and inline alignment are left exactly as you pasted them.
Mixed-indentation lines (1 tab + 2 spaces) are handled correctly because each leading whitespace character is mapped column-by-column. That's the same algorithm Python's expandtabs and the standard expand/unexpand utilities use.
No — only leading whitespace is touched. A line like print("a b") keeps the four spaces between a and b intact, and only the leading tab (or spaces) is converted.
It depends on the language convention: Python uses 4, Go uses tabs that render as 4 or 8, Rust uses 4, and many web stacks (HTML/JS) use 2. The default of 4 is the most common compromise.
Each leading whitespace character is expanded or compressed individually based on the chosen tab width. So 1 tab + 2 spaces with a width of 4 expands to 6 spaces, and 6 spaces compresses to 1 tab + 2 spaces.
Whitespace-sensitive languages (Python, YAML, Makefile) require consistent indentation throughout a block. Converting one block but not another can break parsing. Always run the converter over the whole file, not a snippet.
Explore the full suite of Text tools and 290+ other free utilities at Chunky Munster.