What Is the Convert Tabs/Spaces Tool?
The Convert Tabs/Spaces tool solves the classic developer indentation debate by converting between tab characters and spaces in any direction. Paste code that uses tabs and convert to 2, 4, 6, or 8 spaces — or go the other way and consolidate leading spaces back into tabs. Works with code in any language and runs entirely in your browser with zero setup.
How to Convert Tabs to Spaces
- Choose direction — Tabs → Spaces or Spaces → Tabs.
- Set spaces per tab — 2 (popular in JavaScript/TypeScript), 4 (Python, Java, C#), or match your editor settings.
- Paste your code into the input box or click Sample to load an example.
- Copy or Download the converted code.
Where Can You Use Tab/Space Conversion?
Python Compatibility
Python raises IndentationError on mixed tabs and spaces. Convert all indentation to spaces before running or submitting Python code.
Team Style Guides
Match your project's .editorconfig or ESLint/Prettier settings — convert code before committing to a repo that enforces a specific indentation style.
Code Reviews on GitHub
GitHub renders tabs as 8 spaces, making tab-indented code look unwieldy in PR diffs. Convert to 2 or 4 spaces before sharing a review link.
IDE Migration
Moving from a tab-based editor (Vim default) to a space-based one (VS Code default)? Convert your existing files to match the new environment.
Tabs vs Spaces — When to Use Each
- Use tabs when collaborating with teams whose editors use different visual indent widths. Tabs let each developer see their preferred width without changing the file.
- Use spaces when working with Python (which raises errors on mixed indentation), or contributing to open-source projects that enforce spaces in their style guide.
- 2 spaces — Standard in JavaScript, TypeScript, JSON, Ruby, and most modern web projects.
- 4 spaces — Standard in Python (PEP 8), Java, C#, and most backend languages.
- 8 spaces / 1 tab — Traditional Unix/Linux kernel style; rarely used in modern projects.
Best Practices and Limitations
Always check your project's .editorconfig, .eslintrc, or Prettier config before converting — using the wrong space count will still fail linting even after conversion. If a file has mixed tabs and spaces, convert to spaces first to normalize everything, then convert to tabs if needed — never run Spaces → Tabs on a mixed file.
Limitations: The Spaces → Tabs direction only replaces leading indentation spaces — mid-line spaces (alignment in multi-line objects, table formatting) are intentionally left as spaces. This is correct behavior: only indentation should be tabs, never alignment. Tab characters appearing mid-line in the Tabs → Spaces direction are also converted, which may affect intentional tab-separated data — use a dedicated CSV tool for tabular data.
Share This Tool
End the tabs vs spaces debate — share this free indentation converter with your dev team!