Tab to Spaces
How to Use
📖 Tool Introduction
Tab to Spaces is a small but sharp tool for resolving the eternal inconsistency between tab and space indentation in code and plain text. When you collaborate across machines, paste a snippet into a different editor, or copy code out of a PDF or a web page, you often end up in one of two frustrating situations: code that was indented with tabs on one machine shows up as ragged spaces on another, or a block laid out with spaces refuses to match a project style guide that demands tabs. This tool exposes both fixes as a single click. In tab-to-spaces mode every tab in the whole document is expanded into the number of spaces you choose, with widths of 2, 4 or 8 available to match a particular editor or language convention. In spaces-to-tab mode the tool is more conservative: it only collapses the leading indentation of each line, turning blocks of exactly width-multiple spaces back into tabs, while leaving spaces inside the line itself untouched so that alignment between columns is never damaged. After each run it tells you exactly how many tabs were expanded and how many space blocks were collapsed, so you always know what actually changed. The tool also detects whether the source uses CRLF or LF and keeps that ending in the output, which means a bulk conversion never silently rewrites the line endings of a source file. Everything runs locally in your browser, the original input stays untouched, and you can flip direction and width as many times as you like until the output finally matches your team standard, then copy it straight back into your editor or download it as a clean file. Because it handles full code blocks and long lists equally well, it is a convenient companion for reviewing pull requests, reformatting copied documentation, and normalizing snippets before they go into a shared codebase.
✨ Key Features
- Bidirectional: tab to spaces and spaces to tabs, one click apart
- Three widths: 2, 4 or 8 spaces per tab, matching mainstream conventions
- Smart collapsing: spaces-to-tab only touches leading indentation, never in-line spacing
- Conversion counts: reports expanded tabs and collapsed space blocks
- Endings kept: preserves the original CRLF or LF line-ending style
- Private by design: runs entirely in the browser with zero uploads
📝 How to Use
- Choose the direction at the top: tab to spaces or spaces to tabs
- Pick a tab width: 2, 4 or 8 spaces
- Paste the code or text to convert into the input area
- Click Convert and inspect the normalized indentation in the output
- Confirm the conversion counts, then copy or download the result
⚠️ Notes
- Direction scope: tab-to-spaces expands every tab; spaces-to-tab only collapses leading indent
- Remainders: leftover spaces shorter than one width are kept as spaces so alignment survives
- Width choice: follow your project guide; mixing widths makes indentation look off
- In-line spaces: word spacing inside a line is never altered, only the leading indent
- Source safe: output never touches the input, so you can retry freely