Tab to Spaces Converter

Convert tabs to spaces or spaces to tabs in code. Configurable indent width (2/4/8), preserve indentation, and one-click conversion. 100% free, private,.

How to use

  1. Paste code — Enter text with tabs or spaces
  2. Choose conversion — Select tabs→spaces or spaces→tabs
  3. Copy — Copy the converted text

What Is Tab to Spaces?

Tab to Spaces is a code utility that converts tab characters (\t) into a configurable number of space characters, or the reverse. It eliminates inconsistent indentation when files originate from different editors, contributors, or coding standards. The conversion preserves the visual layout while making whitespace deterministic.

Why Indentation Style Matters

Tabs and spaces look identical in the editor but behave differently across tools: diff utilities flag them as changes, linters reject mixed indentation, and Python actually treats them as syntax errors. Using one style consistently keeps repositories clean and pull requests focused on real changes.

Common Conventions by Language

  • 2 spaces: JavaScript, TypeScript, React, Vue, Ruby, Scala, YAML
  • 4 spaces: Python (PEP 8), Java, C#, PHP, Rust
  • Tabs: Go (enforced by gofmt), Makefiles (required by make)
  • Project-specific: follow the existing file or .editorconfig

How the Converter Works

Every tab character in the input is replaced with the configured number of spaces (default four). When converting the other direction, leading runs of spaces are grouped into tabs based on the same width. Trailing whitespace and inline spaces inside string literals are left untouched so your code's behavior never changes — only its indentation.

Use Cases

Onboarding a new contributor whose editor inserts tabs into a spaces-only repo. Cleaning up legacy code before adopting an automatic formatter like Prettier or Black. Pasting code from documentation that uses one style into a project that uses another. Preparing snippets for a blog post or Markdown file where inconsistent indentation breaks code blocks.

Privacy

Conversion happens entirely in your browser — nothing is uploaded, no telemetry is collected, and the input disappears as soon as you close the tab.

Use the JS Minifier to strip whitespace entirely. Format JSON with the JSON Formatter. Add line numbers with the Line Number Adder.

Frequently asked questions

Why convert between tabs and spaces?

Different projects and editors use different indentation standards. Converting ensures consistency across your codebase.

What's the standard space count?

2 spaces (JavaScript, Ruby) and 4 spaces (Python, Java) are the most common. Some teams prefer tabs.

Does it preserve other whitespace?

Yes. Only tab characters (→spaces) or leading space groups (→tabs) are converted.

Related free tools

  • XML Formatter & Minifier — Beautify or minify any XML — SOAP, RSS, SVG, sitemap. Browser-based parser.
  • XML to JSON Converter — Parse any well-formed XML into a clean JSON tree with attributes and arrays.
  • JSON to XML Converter — Convert JSON to well-formed XML — supports attributes, custom root, declaration.
  • CSV Viewer — Open CSV or TSV files in your browser — sort, search, paginate, export filtered view.
  • JSON to CSV Converter — Convert JSON data to CSV format. Export to spreadsheets easily.
  • CSV to JSON Converter — Convert CSV data to JSON format. Useful for API development.
  • JSON Formatter — Format, beautify, or minify JSON with customizable indentation.
  • JSON Validator — Validate JSON syntax and find errors with line and column numbers.
  • HTML Minifier — Compress HTML by removing comments, whitespace, and line breaks.
  • CSS Minifier — Minify CSS by stripping comments, whitespace, and unnecessary characters.
  • JavaScript Minifier — Compress JavaScript by removing comments, whitespace, and empty lines.
  • Base64 Encoder/Decoder — Encode text to Base64 or decode Base64 back to text. UTF-8 support.

Browse all free tools · Guides and tutorials · PDF tools · Developer tools · Text tools · SEO tools