Convert Tabs to Spaces

Replace every tab with spaces — 2 by default; change it to 4 if your project uses that — to fix mixed indentation before you commit or paste code.

Runs in your browserUpdated
Result

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Tabs to Spaces

  1. Paste your code — tabs are replaced with two spaces.
  2. For four spaces, type four spaces in Replace.
  3. Copy the result.

Spaces back to tabs

Set Find to ^( {4})+… or more simply to four spaces with Regex off, and Replace to . To make the change consistent across a project, add an .editorconfig — generate one with the EditorConfig Generator.

Also searched as: convert tabs to spaces, tab to space converter, spaces to tabs, replace tabs with spaces, fix indentation.

Tools that pair well with the Tabs to Spaces

  • Find and Replace — Paste text and replace words or patterns — case-sensitive or not, whole words only, or with regular expressions and $1 capture groups.
  • Line Ending Converter — See which line endings a file uses and convert them — Windows CRLF to Unix LF or back — for pasted text or a whole batch of files, with trailing-space and tab cleanup on the side.
  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • Remove Extra Spaces — Collapse double spaces, runs of spaces and stray tabs into a single space — line breaks are kept.

Frequently asked questions

How many spaces is a tab?
There’s no fixed rule: 2 is common in JavaScript and web projects, 4 in Python and Java.
Does it only change indentation?
It replaces every tab. To change only leading tabs, use the pattern ^ + and adjust the replacement.
Is my code uploaded?
No. It runs in your browser.
Can I install Tabs to Spaces as a web app and use it offline?
Yes. Tabs to Spaces is an installable web app (PWA) — installed from your browser, not downloaded from an app store. Click Install app at the top of this page in Chrome or Edge (Windows, macOS, Linux, ChromeOS) or on Android, use Share → Add to Home Screen on iPhone and iPad, or File → Add to Dock in Safari 17+ on a Mac. It then opens in its own window with its own icon, and because it runs entirely in your browser it keeps working offline. Firefox on desktop can’t install web apps. How installing works.

Related tools