Tabs to Spaces
Replace every tab, or only the indentation, with 2, 4, 8 or a custom number of spaces. Perfect for code, config files and copied tables.
Convert tabs to spaces (or spaces back to tabs) in any text or code. Choose 2, 4, 8 or custom tab width. Free, private and no signup.
Add your text, code or table data that contains tab characters.
Pick 2, 4, 8 or a custom number of spaces per tab.
Copy the space-indented result or save it as a TXT file.
Need to replace tabs with spaces in your text or code? This free tab to space converter changes every tab character into the number of spaces you choose, and it can also convert spaces back into tabs. Paste your text, pick a tab width of 2, 4, 8 or a custom value, and the converted result appears at once. You can convert every tab in the text, or only the leading indentation at the start of each line, and you can turn on Align to tab stops for column aware conversion and Trim trailing spaces to tidy the end of lines. There is no signup and nothing to install.
Tabs and spaces look the same on screen, yet they behave differently. A tab is one character that each editor draws with its own width, so the same file can look neat in one program and broken in another. Spaces always have the same width, which is why many style guides, code formatters, markdown files, YAML files and plain text documents ask for spaces. This converter fixes mixed indentation in seconds. It runs in your browser, so your code and text are never uploaded or stored, and it keeps your line breaks and other characters unchanged.
Replace every tab, or only the indentation, with 2, 4, 8 or a custom number of spaces. Perfect for code, config files and copied tables.
Switch the other way and turn groups of spaces back into tabs when a project or tool requires tab indentation.
Use column aware conversion so text lines up as it would in an editor, instead of replacing each tab with a fixed number of spaces.
A tab to space converter is an online tool that replaces the tab character (the invisible character you get when you press the Tab key) with regular space characters. Because a tab has no fixed width, programs show it as 2, 4 or 8 columns depending on their settings. Converting tabs to spaces makes the layout identical everywhere.
Developers search for this as convert tabs to spaces, replace tab with spaces, tab to 4 spaces or fix mixed indentation. Writers and data users need it too, for example when a table copied from a spreadsheet or a text file contains tab characters between columns.
Converting indentation takes a few seconds with our free tool.
To check the result afterward, you can compare the original and the converted text with the Text Diff Checker.
There is no single correct answer, because it depends on the language, the project and the team. Use the width that your style guide or formatter expects. The table below shows common choices.
| Tab width | Commonly used for | Notes |
|---|---|---|
| 2 spaces | JavaScript, TypeScript, HTML, CSS, YAML, JSON | Short indentation that keeps deep nesting readable |
| 4 spaces | Python, Java, C#, PHP, Kotlin, Swift | The most common width, and the PEP 8 standard for Python |
| 8 spaces | Classic terminals, some C and Makefile style code | The default tab stop in many terminals |
| Custom | Team rules, documents, plain text tables | Use any number that matches your own standard |
A simple conversion replaces every tab with the same number of spaces. A real tab, however, moves the text to the next tab stop, so the number of columns it fills depends on where it is on the line. When you turn on Align to tab stops, the converter works the same way an editor does. It counts the current column and adds only the spaces needed to reach the next stop. This keeps columns of text and tables lined up after conversion, which is especially useful for data separated by tabs and for text that is aligned in the middle of a line.
Yes. The conversion runs inside your browser, so your text and code are not uploaded, saved or stored. As a general habit with any online tool, avoid pasting secrets such as passwords, private keys or API tokens.
This tool is often one step in a bigger text workflow. These related free tools help with the rest of the job:
Our tab to space converter was built to fix indentation quickly and safely. It supports 2, 4, 8 and custom tab widths, column aware tab stops and conversion in both directions, with no signup and no uploads.
Ready to try it? Scroll back up, paste your text and get consistent indentation in a second.
Quick answers about converting tabs to spaces, choosing a tab width, aligning to tab stops and converting spaces back to tabs.
Paste your text or code into the input box, keep Tabs to Spaces selected, choose a tab width of 2, 4, 8 or a custom number, and the converted result appears instantly. Then copy it or download it as a TXT file. The tool is free, needs no signup and has no usage limit.
Use the width that your project already follows. Four spaces is the most common choice for Python, Java, C# and PHP, two spaces is popular for JavaScript, HTML, CSS, JSON and YAML, and eight spaces matches classic terminal and Linux kernel style. You can also enter any custom width from 1 to 16.
It makes the converter behave like a code editor. Instead of replacing every tab with the same number of spaces, it fills only the distance to the next tab stop, so tab-separated columns and mid-line tabs keep their original alignment. Leave it off for plain indentation conversion, and turn it on for tables and aligned text.
Yes. Choose the Spaces to Tabs mode and set the same tab width the text was written with. The tool groups the spaces at the start of each line into tab characters and keeps any leftover spaces, so the visual indentation does not change.
For most languages, including Python, JavaScript, Java and YAML, converting tabs to spaces is safe and often fixes indentation errors. Be careful with Makefiles, which need real tabs on recipe lines, and with tab-separated data files where tabs are field separators. If tabs inside strings matter, use the Leading indentation only option.
No. Letters, numbers, symbols, emoji and line breaks stay exactly as they are. Only the tab characters (or the spaces, in the reverse mode) are changed, plus trailing spaces if you switch on the trim option.
Yes. The conversion runs in your own browser, so your text is not uploaded, saved or stored on our servers, and no account is required. As a general habit, avoid pasting passwords, API keys or other secrets into any website.
Convert tabs to spaces, number lines, clean text or compare two texts in seconds. Explore free text tools to write, edit and format all your content in one place.
Explore All Text Tools →