Convert spaces into tabs in code formatting

Please log in or register to do it.

This tool converts groups of consecutive spaces in your code into a specified number of tab characters. Simply enter your code, specify the number of consecutive spaces to match, and the number of tabs to output. Then process your text to convert each matching group of spaces into the desired number of tab characters.

Numeric Conversion Settings:

Enter the number of consecutive spaces to match (e.g., 4).
Enter the number of tab characters to use as replacement (e.g., 1).

Examples:

Example 1: 4 Spaces to 1 Tab

Every occurrence of 4 consecutive spaces is replaced with 1 tab.

Before:
    function test() {
        return true;
    }
After:
	function test() {
		return true;
	}

Example 2: 2 Spaces to 1 Tab

Every occurrence of 2 consecutive spaces is replaced with 1 tab.

Before:
  if (x) {
  return x;
  }
After:
	if (x) {
	return x;
	}

Example 3: 3 Spaces to 2 Tabs

Every occurrence of 3 consecutive spaces is replaced with 2 tabs.

Before:
   let x = 5;
After:
		let x = 5;

Example 4: 8 Spaces to 1 Tab

Replaces every occurrence of 8 consecutive spaces with 1 tab.

Before:
        console.log("8 spaces");
After:
	console.log("8 spaces");

Example 5: 5 Spaces to 2 Tabs

Every group of 5 consecutive spaces is replaced with 2 tabs.

Before:
     console.log("5 spaces");
After:
		console.log("5 spaces");

Example 6: 4 Spaces to 3 Tabs

Replaces every occurrence of 4 consecutive spaces with 3 tabs.

Before:
    console.log('More tabs');
After:
			console.log('More tabs');

Example 7: 6 Spaces to 1 Tab

Every occurrence of 6 consecutive spaces is replaced with 1 tab.

Before:
      if(condition){
      doSomething();
      }
After:
	if(condition){
	doSomething();
	}

Example 8: 1 Space to 1 Tab

Every single space is replaced with a tab. (This example is more experimental.)

Before:
 code
After:
	code

Example 9: 3 Spaces to 1 Tab

Every occurrence of 3 consecutive spaces is replaced with 1 tab.

Before:
   while(true) {
   break;
   }
After:
	while(true) {
	break;
	}

Example 10: 7 Spaces to 2 Tabs

Every occurrence of 7 consecutive spaces is replaced with 2 tabs.

Before:
       switch(value) {
       case 1:
       break;
       }
After:
		switch(value) {
		case 1:
		break;
		}
Convert Markdown table into HTML table
Convert hexadecimal encoding into readable text

Your email address will not be published. Required fields are marked *