Tab to Space Converter

Convert tabs to spaces online. Replace every tab character with a set number of spaces, choose a custom tab width, use smart tab stops for true column alignment, or convert only the leading tabs that make up your indentation.


    
Options
0 Tabs found
0 Tabs converted

ToolsSoup's Tab to Space Converter is a free online tool that replaces tab characters in your text or code with spaces in one click. Set how many spaces each tab becomes, switch on smart tab stops so columns line up exactly the way they would in an editor, or limit the conversion to the leading tabs that form your indentation. It's the fast way to normalize indentation when a file mixes tabs and spaces, when a code style guide requires spaces, or when tabs render inconsistently across editors and websites. The converted text appears alongside a count of how many tabs were found and replaced, ready to copy. Everything runs in your browser — no uploads, no sign-up, and your text never leaves your device.

What is a tab to space converter?

A tab to space converter turns the invisible tab characters in a piece of text or source code into ordinary spaces. A single tab takes up a variable amount of visual width depending on the editor's tab width setting, which is why the same file can look neatly aligned in one program and ragged in another. Converting tabs to a fixed number of spaces removes that ambiguity: the indentation becomes the same everywhere, in every editor, terminal, diff view, and web page. This tool lets you pick the number of spaces per tab and optionally use smart tab stops, which advance to the next column boundary instead of always inserting the same fixed count.

How to convert tabs to spaces

Converting tabs with ToolsSoup takes only a few seconds:

  1. Type or paste the text or code that uses tabs into the first box.
  2. Set the spaces per tab (2 and 4 are the most common), and optionally turn on smart tab stops or limit the change to leading indentation tabs.
  3. Click Convert tabs to spaces, check how many tabs were converted, then click Copy result to grab the cleaned-up text.

Fixed spaces vs. smart tab stops

By default each tab is replaced with the exact number of spaces you choose, no matter where it appears on the line. Smart tab stops instead mimic how a real editor expands tabs: a tab advances the cursor to the next multiple of the tab width, so it may insert anywhere from one space up to a full tab width. Fixed spaces are simplest and best for indentation, while smart tab stops are the right choice when tabs are used to align columns of data or comments and you need the spacing to match what you see on screen.

Why convert tabs to spaces?

Many style guides and languages — including PEP 8 for Python and most JavaScript and web projects — recommend spaces over tabs so indentation looks identical for everyone. Spaces also survive being copied into web forms, chat apps, markdown, and documents that strip or mangle tab characters. Converting tabs to spaces before sharing code or pasting it online keeps your formatting intact and avoids the classic mixed-tabs-and-spaces errors that break Python and produce noisy diffs.

Why use this tab to space converter?

  • Replace every tab with a fixed number of spaces of your choosing.
  • Use smart tab stops to align tabs to real column boundaries like an editor does.
  • Convert only leading indentation tabs and leave tabs inside the line untouched.
  • See how many tabs were found and converted at a glance.
  • Keep your code's formatting consistent across every editor and website.
  • Result is ready to copy with a single click.
  • Runs entirely in your browser — your text is never uploaded.

Frequently asked questions

How many spaces should a tab be?

It depends on the language and your style guide. Four spaces is the most common default and what Python's PEP 8 recommends, while many JavaScript, TypeScript, and web projects use two spaces. Set Spaces per tab to match your project's convention before converting.

What do smart tab stops do?

With smart tab stops on, each tab expands to the next column boundary — the next multiple of your tab width — exactly like a code editor. So a tab can insert anywhere from one space up to a full tab width depending on its position, which keeps columns of aligned data lined up correctly.

Can I convert only the indentation tabs?

Yes. Turn on Convert leading tabs only and the tool replaces just the tabs at the start of each line — your indentation — while leaving any tabs inside the line, such as those used to separate columns, exactly as they were.

Why convert tabs to spaces at all?

Tabs render at different widths in different editors, so a file can look aligned in one and ragged in another. Spaces always take the same width, so converting tabs to spaces makes indentation consistent everywhere and avoids mixed tabs-and-spaces errors that break Python and create noisy diffs.

Does it change spaces back into tabs?

No — this tool only converts tabs into spaces. To go the other way and turn leading spaces back into tabs, use the Space to Tab converter or the tabs option in the Whitespace Remover.

Is my text private?

Absolutely. All conversion happens locally in your browser using JavaScript, so the text you enter is never sent to or stored on any server.