Paste your text or code
Source code, a configuration file, a table or plain text with tabs.
Paste your text or code and convert its tabs to spaces, or its indentation spaces to tabs. Set how many spaces one tab is worth: 2, 4, 8 or any width up to 16.
100% private — your text is processed in your browser and never sent to any server.
Source code, a configuration file, a table or plain text with tabs.
Tabs to spaces, or indentation spaces to tabs, with the number of spaces per tab.
The change count tells you how many replacements were made.
Whether to indent with tabs or with spaces is a long-running debate among programmers, but in practice the problem is usually that a file contains the wrong one for the place where it is going. A project may require spaces, a Makefile requires tabs, a YAML file forbids tabs for indentation, a forum post needs spaces to keep the alignment, and a text pasted between editors can end up with a jumble of both. This tool converts a text from one convention to the other.
Every tab character is replaced by the number of spaces you choose: 2, 4 and 8 are the usual values. This simple rule has one limit that is worth knowing: a real tab jumps to the next tab stop, so its width depends on where it sits in the line, whereas this tool substitutes a fixed number of spaces. For indentation at the start of a line the result is exactly what you want. For tabs in the middle of a line, used to align columns, the alignment may change.
The option "only the tabs at the start of a line" converts the indentation and leaves tabs inside the line untouched. That is the safer choice for code and for tab-separated data, where tabs in the middle of a line separate columns and must not become spaces.
The opposite conversion turns the spaces that begin a line into tabs, one tab for each group of the chosen number of spaces. A line indented with eight spaces becomes two tabs when the width is four. Leftover spaces that do not fill a group are kept as spaces, so no alignment is lost, and spaces in the middle of a line are never touched.
The tool does not detect the indentation style of your file, does not reformat code and cannot tell whether a tab is inside a string or a comment. For code with strict layout rules, such as Python or YAML, check that the structure is still valid after converting.
More utilities that also run without leaving your browser.