Free code formatting tool

Tab to Space Converter

Convert tabs to spaces or spaces to tabs in one click. Set how many spaces equal a tab and watch the conversion and character count update live.

Input

Paste code or text

Converted

Live result
Paste text to see conversion stats.

Switch between tabs and spaces instantly

Two directions, one tool

Convert Tabs to Spaces or Spaces to Tabs without switching pages or reconfiguring settings.

Any tab width

Set a custom spaces-per-tab value or pick a 2, 4 or 8 space preset to match your project's style guide.

See what changed

A live stat line reports exactly how many tabs or space groups were replaced.

How to convert tabs and spaces

  1. Pick a directionChoose Tabs to Spaces or Spaces to Tabs at the top of the tool.
  2. Set the widthEnter a spaces-per-tab value or use the 2, 4 or 8 preset buttons.
  3. Copy the resultPaste your text, review the live conversion, then copy or download it.

Tabs vs spaces for indentation

The tabs-versus-spaces debate has followed programmers for decades, and most teams eventually settle on one convention enforced by a linter or editor config. Tabs are a single character that each editor can render at its own preferred width, which makes them flexible for personal preference but risky when a file is viewed somewhere that assumes a different width, since alignment can shift unexpectedly. Spaces render identically everywhere because every space is exactly one column wide, which is why many style guides, including several popular ones for Python, JavaScript and Go-adjacent tooling, standardize on spaces despite the larger file size. Mixed files are the real problem in practice: when tabs and space-based indentation exist side by side, lines that look aligned in one editor can appear staggered in another, and diffs become noisy. This converter lets you move a whole document to one convention or the other in a single pass, using an exact character-for-character replacement so the underlying structure of your code or text never changes, only the whitespace representation.

Pick one convention

Consistency across a file or project avoids the alignment drift that mixed indentation causes.

Match your linter

Many formatters and style guides enforce a specific tab width; convert your file to match before committing.

Safe, reversible edits

Conversion only touches tab characters or space runs, so content and line breaks stay exactly as they were.

Tab to space converter FAQ

How does the tab to space converter work?

Choose a direction, either Tabs to Spaces or Spaces to Tabs, set how many spaces represent one tab, then paste your text. The conversion updates live and the result is ready to copy or download.

How does Spaces to Tabs handle leftover spaces?

Runs of spaces are converted in full tab-width chunks. If a run of spaces is not an exact multiple of the tab width, the remainder stays as spaces so alignment is preserved.

What are common spaces-per-tab values?

2, 4 and 8 spaces per tab are the most common conventions, with 4 being the default for many programming style guides. Presets for all three are built into the tool.

Does this affect anything besides tabs and spaces?

No. The converter only replaces tab characters or runs of spaces depending on the direction you choose. All other characters, including line breaks, are left untouched.

Is this tab to space converter free and private?

Yes. It runs entirely in your browser, requires no account, and your text is never uploaded to a server.

Try other text tools