Tabs to Spaces
Normalise indentation in code or notes with a single click.
How Tabs to Spaces works
Convert tabs to a chosen number of spaces, or turn space indentation back into tabs. Everything happens inside this page: the tool reads your input, runs the calculation or conversion locally, and hands the result back to you. Nothing is transmitted, because there is no backend to transmit it to.
That design choice is deliberate. Most free tool sites upload your files to a server, process them there, and quietly keep a copy. Toolcin cannot do that — the site is a set of static files. If your connection dropped the moment the page finished loading, every tool would still work.
Converting indentation
Every tab character is replaced by the number of spaces you choose, default 4. That is a character substitution, not a visual re-indent: a tab in the middle of a line is converted too.
The reverse mode looks for runs of exactly that many spaces and turns them into a tab. It only works cleanly when the file was consistently indented in the first place — mixed 2- and 4-space indentation produces a mess in either direction.
Why editors disagree
A tab is one character that the editor renders at a configurable width; four spaces are four characters that always look the same. That is the whole argument: tabs are smaller and user-configurable, spaces are consistent everywhere.
Most language style guides now specify spaces, and Go's formatter enforces tabs. Match the project, not the preference.
| Language | Convention |
|---|---|
| Python | 4 spaces (PEP 8) |
| JavaScript | 2 spaces typical |
| Go | Tabs, enforced by gofmt |
| Makefile | Tabs required — do not convert |
The Makefile warning
In a Makefile, a tab at the start of a recipe line is syntax, not formatting. Converting those tabs to spaces breaks the file with a confusing “missing separator” error.
If you are converting a whole repository, exclude Makefiles, .mk files and any language where the tab is significant.
Good to know
- Works offline once loaded, including on flights and in locked-down networks.
- No file size limit beyond your device's own memory.
- Free to use, with no account and no usage counter.
- Results are produced locally, so they are not logged or shared with anyone.
Questions
Which tab width should I use?
Four spaces for most languages, two for JavaScript and YAML.
Can it convert back?
Yes — switch to the reverse mode.
Does it convert tabs inside strings?
Yes. This is a blind character substitution, so check string literals afterwards.
Can I use a tab width of 2?
Yes, any width from 1 upward.
Keep going
More converters tools
cm to in
Convert centimetres to inches instantly. 1 cm = 0.3937008 in, with a live result and a quick reference table.
Open toolmm to in
Convert millimetres to inches instantly. 1 mm = 0.03937008 in, with a live result and a quick reference table.
Open toolin to cm
Convert inches to centimetres instantly. 1 in = 2.54 cm, with a live result and a quick reference table.
Open toolkg to lb
Convert kilograms to pounds instantly. 1 kg = 2.204623 lb, with a live result and a quick reference table.
Open toollb to kg
Convert pounds to kilograms instantly. 1 lb = 0.4535924 kg, with a live result and a quick reference table.
Open toolg to oz
Convert grams to ounces instantly. 1 g = 0.03527396 oz, with a live result and a quick reference table.
Open tool