# Tab-Space Converter > Convert between tabs and spaces with configurable tab width **Category:** Dev **Keywords:** tabs, spaces, indentation, whitespace, code formatting, convert tabs, detab **URL:** https://complete.tools/tab-space-converter ## Why indentation style matters Most style guides and linters enforce a consistent indentation character. Python requires consistent indentation within a block. JavaScript projects typically enforce either 2-space (Prettier default) or 4-space (many legacy projects) indentation. Go enforces tabs via gofmt. Mixing tabs and spaces causes syntax errors in Python and visual misalignment everywhere else. When collaborating across editors and operating systems, tabs display at different widths depending on the editor setting. Spaces always render at exactly their defined width, making them portable. Converting to spaces before committing ensures the code looks identical to every reviewer. ## Tab width options **2 spaces** is the standard for JavaScript, TypeScript, JSON, HTML, CSS, and Ruby projects following modern style guides (Prettier, Airbnb, Google). **4 spaces** is common in Python (PEP 8), PHP, C#, Java, and many older JavaScript codebases. **8 spaces** matches the historical Unix/terminal default tab stop and is still used in some C and kernel code where tabs are required by the style guide but display correctly only at 8 spaces. ## How to use 1. Paste your code into the input box 2. Select the conversion direction: **Tabs to Spaces** or **Spaces to Tabs** 3. Choose your tab width (2, 4, or 8 spaces) 4. Click **Convert** 5. Copy the output with the Copy button ## FAQs **Q:** Does this handle mixed indentation (some tabs, some spaces)? **A:** The tabs-to-spaces direction replaces every tab character regardless of context. The spaces-to-tabs direction matches exact groups of N consecutive spaces, so lines with mixed or partial-width indentation may not convert perfectly. For complex mixed-indentation files, a dedicated formatter like Prettier or editorconfig is more reliable. **Q:** Will this change anything other than leading indentation? **A:** Tabs-to-spaces replaces all tab characters, including those inside strings or between words. If your code uses tabs for alignment inside strings, review the output before committing. Spaces-to-tabs only matches exact runs of N spaces, so spaces inside strings are usually unaffected. **Q:** Is there a file size limit? **A:** No. All conversion happens in your browser. There is no server upload or file size limit beyond what your browser can handle in memory. **Q:** Why does my code look misaligned after converting? **A:** This usually means the original code mixed tabs and spaces, or the tab width used to write it differs from what you selected. Try a different tab width setting. --- *Generated from [complete.tools/tab-space-converter](https://complete.tools/tab-space-converter)*