AnkhKit

Convert Tabs to Spaces Online — 2, 4, or 8 Spaces — Free

Runs 100% in your browser — your files never leave your device.

Style guides and linters disagree, but sometimes you just need the indentation flipped. Paste your code or text, choose how many spaces each tab becomes — 2, 4, or 8 — and copy the converted result. It is the fastest way to satisfy an editor that insists on spaces. The conversion happens entirely in your browser, so private code never leaves.

How it works

  1. 1

    Paste your code or text

    Tab-indented content works best.

  2. 2

    Choose the space width

    Pick 2, 4, or 8 spaces per tab.

  3. 3

    Copy the converted text

    The spaced version appears live and copies with one click.

About this tool

Why the conversion matters

Tabs and spaces render differently everywhere: tabs expand to whatever width a viewer prefers, which is why code aligned on your machine looks scrambled in someone else's diff. Converting to spaces freezes the alignment for every viewer, every platform, forever.

The conventions worth knowing

Most style guides call for spaces — commonly 2 or 4 per tab — precisely because they render identically everywhere. Python treats the mix seriously (mixing tabs and spaces in one file is an error), which makes conversion a required step when pasting code between sources.

Converting without breaking code

The tool replaces each tab with your chosen number of spaces, preserving column positions as long as you pick the width the original author used. For the reverse direction, the spaces-to-tabs converter runs the same job backward.

Frequently asked questions

How many spaces should one tab become?

Match the convention of your destination: 2 spaces is common for web code, 4 for Python and most classic style guides. The original alignment survives when the width matches.

Why does mixed indentation break Python?

Python reads indentation as structure, and a tab and four spaces look identical but count differently. Converting everything to spaces makes the structure unambiguous.

Will my code still work after conversion?

Yes — the characters change but the visual indentation stays identical, so Python, YAML, and Makefile logic are unaffected when the width matches.

More text tools