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.

LanguageConvention
Python4 spaces (PEP 8)
JavaScript2 spaces typical
GoTabs, enforced by gofmt
MakefileTabs 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