Tabs and Spaces Converter

Turn leading tabs into spaces or spaces into tabs, with the indent size you choose. Only the indentation at the start of each line changes.

Processed on your device. Files are not uploaded

How to convert tabs and spaces

  1. Paste your text or code

    Paste or type it into the box, or press Try an example.

  2. Choose tabs or spaces

    And the size of an indent.

  3. Copy or download

    Paste the re-indented code back into your file.

Worked example

This is what Tabs and Spaces Converter gives for its own sample values. Open the tool above and change anything to try your own.

Code or text

function hello() {
	if (true) {
		return 1;
	}
}
Convert to
Spaces
Spaces per indent level
2

Converted text

function hello() {
  if (true) {
    return 1;
  }
}

About Tabs and Spaces Converter

Turn the tabs at the start of each line into spaces, or runs of spaces into tabs, with the indent size you choose. Only the indentation changes, so tabs inside a line are left alone.

FAQs

Does it change tabs inside lines?

No. Only leading whitespace is converted.

What indent size should I choose?

2 or 4 spaces are most common. Match the project you are working in.

Can I set the rule for a project?

Use .editorconfig Generator.

Related tools