Convert spaces to tabs

Turn space indentation into tabs.

Convert
Tab width

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to convert spaces to tabs

  1. Paste your code into Input.
  2. Set Tab width to the number of spaces per indent level in your text, such as 4.
  3. Copy the result. Each full group of spaces at the start of a line is now one tab.

When you need tabs

  • Makefiles, where every recipe line must start with a tab. Spaces give a “missing separator” error.
  • Go code, which gofmt indents with tabs.
  • Projects whose style guide or .editorconfig file sets indent_style = tab.
  • Pasting code into a file that already uses tabs, so the indentation matches.

Why some people prefer tabs

A tab is one character per indent level, so each person can set the display width they like in their editor without changing the file. Someone who likes deep indentation sees 8 columns, someone on a laptop sees 2, and the file stays the same. The trade-off is that lining things up inside a line, such as a column of comments, only works reliably with spaces. That’s why this tool converts indentation and leaves the rest of each line alone.