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:
CommentsConvert between spaces and tabs — auto-detect indent size, configurable tab width, side-by-side preview.
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
- 1Paste your code into the left panel.
- 2Choose Spaces → Tabs or Tabs → Spaces.
- 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
XML Formatter
Format, beautify, and validate XML documents online. Handles namespaces, CDATA sections, and mixed content.
SQL Formatter
Format and beautify SQL queries. Supports SELECT, JOIN, subqueries, CTEs, and multiple SQL dialects.
Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, and more.
Text Diff
Compare two text snippets side-by-side and highlight the differences. Word- and line-level diff, everything runs in your browser.
Word Counter
Count words, characters, sentences, paragraphs, and reading time in any text. Includes a byte-size estimate for storage planning.
Markdown → HTML
Convert Markdown to HTML with a live preview. Supports GitHub Flavored Markdown (tables, task lists, strikethrough, code fences). Free, no signup, runs entirely in your browser.