Spaces to Tabs
Convert leading spaces back into tab characters, for consistent code indentation.
Converts a file's leading indentation from spaces back to tabs, for codebases or style guides that require tab-based indentation — only leading whitespace on each line is touched, so spaces between words or mid-line are left alone.
Example: A line indented with 8 leading spaces converts to 2 tab characters when the tab width is set to 4, collapsing the leading whitespace without touching spacing elsewhere on the line.
How it works
- Paste space-indented text or code
- Set how many spaces equal one tab
- The converted result appears instantly, on your device
Frequently asked questions
Does this touch spaces in the middle of a line?
No — only leading indentation at the start of each line is converted to tabs. Spaces between words or code tokens are left exactly as they are.
Is my text uploaded anywhere?
No — Spaces to Tabs runs entirely in your browser using JavaScript/WebAssembly. Your text is never sent to a server.
What happens if the leading spaces aren't an exact multiple of the tab width?
The leftover spaces that don't make a full tab are kept as plain spaces after the converted tabs, so no whitespace is silently dropped.