Skip to main content
NyankoTools

Indent Converter (Tabs, Spaces, Width)

Convert only the indentation at the start of each line: tabs to spaces, spaces to tabs, or a new width such as 2 spaces to 4. It does not reformat your code, and tabs, spaces and line endings in the middle of a line are left alone. To normalize line endings too, try the Line Ending Converter.

🔒 Runs in your browser · Your data is never sent to a server

Conversion
Result

Notes

  • Only the whitespace (tabs and spaces) at the start of each line is converted. Tabs and spaces inside a line, including string literals, are never touched.
  • Lines that mix tabs and spaces are measured in columns using tab stops (multiples of the width you set) before being converted.
  • With "Spaces to tabs", leftover spaces that do not fill a whole tab are kept as spaces so that alignment is preserved.
  • The tool does not detect your original indent size. If the width you enter differs from the real one, the nesting depth will shift, so check it first.
  • Be careful with formats where tabs are significant (Makefile, TSV) or where indentation is syntax (Python): test the result after converting.
  • Everything runs in your browser; the text you enter is never sent to a server.

FAQ

How is this different from a code formatter?

It only replaces the tabs and spaces at the start of each line. Braces, line breaks and whitespace inside a line are not reformatted, so the diff stays small when you only want consistent indentation.

How are lines that mix tabs and spaces handled?

The leading whitespace is measured in columns using tab stops (multiples of the width you set), then rewritten as tabs or spaces from that column count. The visual depth stays the same.

How do I change 2-space indentation to 4 spaces?

Choose "Change space width", set the current width to 2 and the new width to 4. Each 2-space level becomes 4 spaces, and any odd leftover space is kept as it is.

Are tabs and spaces inside strings converted?

Whitespace in the middle of a line is never changed. However, leading whitespace on the continuation lines of a multi-line string or heredoc is converted like any other indentation.

Share this page

↑↓ Select Enter Open Esc Close