Convert Spaces to Tabs

Compress leading spaces into tabs instantly.

Options

Spaces per tab stop. 1 to 32, default 4.

The result updates as you type. Ctrl + Enter converts now.

Text with tabs

How to convert spaces to tabs

Paste your text into Your text, or press Load example. Set the Tab size (default 4) and the leading spaces are compressed into tabs instantly, updating as you type. Copy the result or download it as a .txt file. Everything runs in your browser, so nothing you paste is uploaded.

Examples

InputOutput
indented → one tab
deeper → two tabs
two spaces stay unchanged (no full tab stop)

Limits and edge cases

  • Only leading spaces are converted. Spacing between words and inside a line is never touched, which keeps code and aligned columns safe.
  • Conversion uses true tab-stop math: a tab jumps to the next multiple of the tab size. Leftover spaces that do not reach a full stop stay as spaces.
  • Lines that already start with tabs are left alone; existing tabs are never rewritten or expanded.

Frequently asked questions

How do I convert spaces to tabs?

Paste your text into the input box and set the tab size. Leading spaces are compressed into tabs instantly, using true tab-stop alignment.

Are spaces inside a line changed?

No. Only leading spaces at the start of each line are converted. Spacing between words and code alignment inside a line is left untouched.

What is tab-stop alignment?

A tab jumps to the next multiple of the tab size. With size 4, four leading spaces become one tab, six leading spaces become one tab plus two spaces, and two leading spaces stay as spaces because they do not reach a full stop.

What happens to tabs that are already there?

Existing tabs are kept as they are. Only runs of leading spaces are converted, so lines that already use tabs are not disturbed.

Why only leading whitespace?

Converting spaces in the middle of a line can break alignment and code formatting. Limiting conversion to leading indentation is the safe option that never changes how content lines up.

Is my text uploaded anywhere?

No. Conversion runs in your browser with JavaScript and nothing is sent to a server. Inputs under 200 KB are kept in your browser's local storage so they are still there when you come back.