Tabs to Spaces / Spaces to Tabs Converter Convert indentation between tabs and spaces.
100% offline
Tab width
4
Input91 chars · 6 lines
Output106 chars
Converted · 6 lines
function greet(name) {
    if (name) {
        return "Hello, " + name;
    }
    return "Hello, world";
}

About Tabs to Spaces / Spaces to Tabs Converter

Indentation should be consistent, but real-world files mix tabs and spaces all the time — pasted snippets, different editors, and team conventions all leave their mark. This tool converts tabs to spaces and spaces to tabs at whatever tab width you choose, so you can normalise code and config files in seconds.

It works only on the leading indentation of each line, so a tab or run of spaces inside your content is left exactly as it was. Pick a direction, set the tab width (2, 4, or 8), and the converted result updates live.

Everything runs in your browser. The text you paste is never uploaded, which makes it safe for proprietary source and private config.

Features

  • Convert tabs to spaces and spaces to tabs in one click
  • Configurable tab width (2 / 4 / 8) with correct tab-stop handling
  • Touches only leading indentation — inline whitespace is preserved
  • Live preview, one-click copy, and fully offline

How to use

  1. Paste your indented text or code into the input pane.
  2. Choose “Tabs → Spaces” or “Spaces → Tabs”.
  3. Set the tab width to match your project (commonly 2 or 4).
  4. Copy the converted output from the right pane.

Frequently asked questions

Does it change tabs or spaces inside my code, not just the indentation?

No. Conversion is applied only to the leading run of whitespace at the start of each line. A tab used for alignment inside a line, or spaces between words, are left untouched.

How does the tab width affect the result?

When converting tabs to spaces, each tab expands to fill the next tab stop at that width. When converting spaces to tabs, every full group of that many leading spaces becomes one tab, and any leftover spaces stay as spaces.

Is the conversion reversible?

For clean indentation, yes — tabs → spaces → tabs (at the same width) restores the original. Mixed or partial indentation is normalised deterministically, so the output is consistent even when the input was not.

Is my data sent to a server?

No. All conversion happens locally in your browser. Nothing you paste leaves your device, so it is safe to use on private or proprietary files.

Everything runs locally in your browser — your input is never uploaded.