Tab / Space Converter

Paste your code to convert indentation between tabs and spaces. Supports custom tab width and leading-indent-only conversion.

Last updated: 2026/10/16 Developer Feedback & bug reports
Conversion Options
Direction
Tab Width
 

When off, tabs and spaces inside the line are also converted.

Input
Result
Lines changed: 0
Total lines: 0

How to Use

1

Paste Your Code

Paste code that is indented with tabs or spaces into the input field.

2

Choose Options

Select the direction (tabs to spaces or spaces to tabs) and tab width. Keep the option on to convert leading indentation only.

3

View the Result

The converted result appears in real-time as you type. The number of changed lines is also shown.

4

Copy and Use

Click Copy to save the result to your clipboard and paste it into your editor.

About the Tab / Space Converter

A web tool that converts indentation in source code between tab characters and spaces. You can choose a tab width of 2, 4, or 8 and limit conversion to leading indentation. All processing happens in your browser, so the code you paste is never sent to any server.

Features

  • Real-time ConversionConverts instantly as you type. No waiting for results.
  • Selectable Tab WidthChoose a tab width of 2, 4, or 8 spaces to match your project style.
  • Leading Indent OnlyConvert only leading indentation to avoid breaking spaces inside strings.
  • Privacy ProtectedAll processing happens in your browser. Code is never sent to servers.

Use Cases

  • Unify indentation to match your team coding style (tabs vs. spaces)
  • Format indentation-sensitive languages like Python and YAML
  • Normalize indentation to reduce noise in Git diffs
  • Fix broken indentation in copied code
  • Clean up Markdown code blocks and snippets

FAQ

Is the Tab / Space Converter free to use?
Yes, it is completely free. No registration required, and you can start using it as soon as you open the page.
What does "Convert leading indentation only" mean?
When enabled, only the consecutive tabs and spaces at the start of each line (the indentation) are converted, leaving spaces and tabs within the line untouched. This is useful when you do not want to alter spaces inside string literals or aligned tables. When disabled, the entire line is processed.
Which tab width should I choose?
Match it to your language or project style. Python commonly uses 4, tab-oriented projects often treat tabs as 8, and web code (JavaScript/CSS) often uses 2 or 4.
Spaces-to-tabs is converting spaces inside my text too.
Turn on "Convert leading indentation only". When it is off, every run of spaces matching the tab width is replaced with a tab, including spaces inside the line.
Is the code I paste sent to a server?
No. Your code is never sent to or stored on any server. All conversion runs entirely in your browser with JavaScript, so it is safe to use even with sensitive source code.