Convert tabs to spaces and spaces to tabs, real tab-stop alignment, leading-indent or whole-line, all in your browser
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
A tab fills to the next column that is a multiple of the tab width, so code stays aligned the way an editor shows it.
What this tool does
A precise tabs-to-spaces and spaces-to-tabs converter for normalising code indentation. Paste a file, pick a tab width of 2, 4, 8 or any custom value, and convert in either direction. The tab-to-space mode does it the right way: instead of blindly swapping each tab for a fixed number of spaces, it aligns to the next tab stop, so a tab sitting at column 2 fills only to column 4 and your code lines up exactly the way an editor renders it. If you would rather have a flat replacement, a second mode turns every tab into exactly N spaces. Going the other way, the spaces-to-tabs mode collapses each full group of leading spaces back into one tab and leaves any leftover spaces alone. Choose whether to touch only the leading indent (the safe default for code, leaving tabs inside strings or trailing alignment untouched) or the whole line. Everything runs client-side, one click copies the result, and the shareable URL reopens the exact same conversion. No upload, no server.
Tool details
- Input
- Text + Numbers
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Preview
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How Tabs to Spaces Converter fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 Text File Cleaner Upload a text file and remove BOM, null bytes, trailing spaces, and excessive final blank lines locally. Open
- 2 .editorconfig Generator Visual .editorconfig builder — indent, charset, line endings, trailing whitespace, per-glob overrides — browser-only Open
- 3 Find and Replace Text Batch find-and-replace on big text — regex, $1 capture groups, whole-word, case toggle, multiple chained rules — runs entirely in your browser Open
Real-world use cases
Enforce a project's indentation rule before committing
Your repo's style guide says 2 spaces, but a teammate's editor inserts tabs. Before you push, paste the changed file, set tab width 2, convert tabs to spaces in leading-indent-only mode, and copy the result back. The diff now contains only the lines you actually changed, not a wall of whitespace churn, and the pre-commit linter passes on the first try.
Fix a Python TabError without hunting line by line
A script throws "inconsistent use of tabs and spaces in indentation" and the offending line is invisible to the eye. Paste the whole file, width 4, tabs to spaces, leading indent only. Every level becomes plain spaces, the ambiguity is gone, and the interpreter runs the file. No more squinting at columns trying to spot the rogue tab.
Prepare a code snippet for a blog post or Markdown
Markdown and many web code blocks render tabs at the browser default of 8 columns, which blows your carefully-indented sample out of shape. Convert tabs to spaces at width 2 or 4 first, and the snippet looks the same everywhere it is pasted, from a CMS editor to a GitHub README to a Slack message.
Convert spaces back to tabs for a tab-first codebase
You are contributing to a Go project or a Makefile where tabs are required, but the file you generated uses spaces. Switch to spaces to tabs, set the matching tab width, and every full group of leading spaces collapses into one tab. Makefiles in particular only accept real tabs for recipe lines, so this is the difference between a build that runs and one that errors with "missing separator".
Common pitfalls
Picking the wrong tab width for the file. If the original code was indented with width 8 tabs but you convert at width 4, every indent level halves and nested blocks look wrong. Match the tab width to how the file was actually authored before converting, not to your personal preference.
Using fixed N spaces when you needed align-to-tab-stop. Fixed mode is fine for pure leading indent, but if the file has tabs after text (column alignment, inline tables) fixed mode over-fills and breaks the layout. Use align-to-tab-stop for any file where tabs do more than indent.
Converting the whole line when only the indent should change. Whole-line mode will happily rewrite a tab inside a string literal or the spaces you used to align trailing comments. For source code keep leading-indent-only on so the conversion stays limited to the indentation.
Privacy
Every conversion runs as plain JavaScript inside your browser tab. Your code never leaves the page, nothing is uploaded, and there is no logging of what you pasted. The one caveat: the shareable URL encodes your input and options in the query string, so a "share link" pasted into a chat will record that text in the recipient server's access log. For private or proprietary code, use the copy button and paste the cleaned text instead of sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only