DevKits

Indentation Converter — Convert Spaces to Tabs & Tabs to Spaces Online

Convert between spaces and tabs in your code. Auto-detect the space count per indent level. Configurable tab size. Side-by-side preview. 100% local.

Last updated:

Comments

Convert between spaces and tabs — auto-detect indent size, configurable tab width, side-by-side preview.

Detected: 2 spaces per indent → tabs
function greet(name) {
		console.log("Hello, " + name);
		if (name === "Alice") {
				return "Welcome back!";
		}
		return "Nice to meet you!";
}

What is Indentation Converter?

Indentation style is one of the most common formatting disagreements in teams. Python (PEP 8) mandates 4 spaces. Go (go fmt) uses tabs. JavaScript frameworks vary (2 spaces for React, 4 for Angular). Converting between them by hand is tedious and error-prone — this converter handles it automatically, counting leading whitespace per line and replacing it with the target indentation.

How to convert indentation

  1. 1Paste your code into the left panel.
  2. 2Choose Spaces → Tabs or Tabs → Spaces.
  3. 3The converted output appears in the right panel. Copy and paste back into your editor.

Frequently Asked Questions

How does the converter handle mixed indentation?

It counts leading whitespace per line and replaces it with the target indentation style. Mixed spaces and tabs in the same line are folded into a single indent level before conversion.

What tab size should I use?

2 spaces: React, Vue, Svelte, most JavaScript/TypeScript. 4 spaces: Python (PEP 8), Go, Rust, most backend languages. 8 spaces: Linux kernel. Tabs: Go (go fmt uses tabs), Makefiles (require tabs).

Try Next

Regex Tester

Test regular expressions online with live match highlighting, capture-group and named-group output, and every JavaScript flag (g, i, m, s, u, y). Free, no signup, no ads — runs entirely in your browser.

Related Tools

Reference & Guides