Tabs to Space Converter

Tabs to Space Converter — Turn tabs into spaces — or spaces back into tabs — across Free to use online, no sign-up; runs 100% in your browser on ScopeTreasure.

In short: Turn tabs into spaces — or spaces back into tabs — across a whole file. Free to use in your browser — no sign-up.

What is Tabs to Space Converter?

Tabs to Space Converter changes indentation across a whole text: tabs become spaces (2, 4 or 8 per tab), or leading spaces become tabs. It fixes mixed indentation in code and pasted text.

How to use this tool

  1. Paste your code or text into the box.
  2. Pick the direction: tabs to spaces, or spaces to tabs.
  3. Pick how many spaces one tab means: 2, 4 or 8.
  4. Press Convert and read the result below.
  5. Press Copy to paste the fixed text back into your editor.

About this tool

Tabs and spaces look the same on screen but are different characters, and mixing them breaks code. Python refuses to run a file with mixed indentation, and other languages render it oddly. Pasting code from a web page often turns tabs into spaces or the reverse. This tool converts the whole text in one direction, so the indentation is consistent again.

Tabs to spaces replaces every tab with the spaces you pick: 2, 4 or 8. Four is the common choice for most languages. Spaces to tabs does the reverse at the start of each line: every group of 4 spaces becomes one tab — only at the line start, so spaces inside the line, such as between words, are left alone.

The count underneath says how many tabs or space-groups were changed, so you can check the conversion did what you expected. Lines that were already consistent stay unchanged, and blank lines are left alone.

Everything runs on your device: the text is converted locally and never sent anywhere. Long files work fine — a full code file converts in one click.

Example — Python code and pasted code:

A student’s Python file will not run because the indentation mixes tabs and spaces. She pastes the file, picks tabs to spaces with 4 spaces, presses Convert and gets 48 tabs replaced — the file runs cleanly afterwards.

A developer pastes code from a web page where the tabs became 8 spaces. He picks spaces to tabs with 4 spaces and the indentation is compact and consistent again.

Frequently asked questions

How do I convert tabs to spaces?
Paste the text, pick “Tabs to spaces”, choose 2, 4 or 8 spaces per tab, and press Convert. Then press Copy.
How many spaces should one tab be?
Four is the common choice for most languages. Two suits compact code; eight matches the old terminal default.
Can I convert spaces back to tabs?
Yes. Pick “Spaces to tabs” — groups of spaces at the start of each line become tabs. Spaces inside a line are left alone.
Why does mixed indentation break code?
Tabs and spaces are different characters. Python refuses mixed indentation, and other languages render it oddly.
Does it change spaces between words?
No. Spaces to tabs only touches leading spaces at the start of a line.
What does the count mean?
How many tabs or space-groups were changed, so you can check the conversion did what you expected.
Is my code private?
Yes. The conversion runs in your own browser and your code never leaves your device.
Can I convert a whole file?
Yes — paste the whole file and convert it in one click.

Related Text & Utilities tools