leading-only · all · configurable width

Convert tabs ↔ spaces

Convert tabs to spaces (any width) or back. Leading-only mode preserves intra-line tabs in strings.

Tabs ↔ Spaces Workspace
Lines
4
62 B
Direction
tabs → spaces
tab=4
Scope
leading
indent only
Output size
71 B
converted
Tab width
input · code
output
function hello() {
    return 'world';
        console.log('nested');
}
Quick Start

How to convert tabs and spaces

Normalize indentation across files or codebases. Leading only is safer for source code (preserves tabs inside string literals).

  1. 01

    Paste text

    Code or any indented text.

    Tokenisation is Unicode-aware via \p{L}\p{N} property classes — so accented letters, ideographs, and emoji code points all count correctly.

    codeUTF-8Unicodecode pointslive
    input · textraw · UTF-8
    \tfunction()
    loaded · UTF-8UTF-8 · ready
  2. 02

    Direction & width

    Tabs → spaces (expand) or Spaces → tabs (compact). Tab width = how many spaces per tab.

    Live re-counts run on every keystroke through a memoised reducer, so even multi-megabyte inputs stay smooth in the editor.

    directionlivememoisedoptionssnappy
    config · options→ · live
        function()
    options applied · livelive
  3. 03

    Scope

    Leading only = first run of whitespace per line. All = every occurrence (less common).

    Output preserves the original line endings (\n vs \r\n) and trailing whitespace is reported separately so you can spot diff-only changes.

    leadingallline endingswhitespacediff-clean
    scope · countedleading · ready
    indent only
    counted · livecounted
  4. 04

    Copy or download

    One click.

    Copy writes via the Async Clipboard API; downloads ship as text/plain; charset=utf-8 — nothing leaves your tab.

    copyclipboardtext/plainblobclient-side
    export · copiedready · done
    ✓ Copied
    shipped · ready to shipsuccess
Pro tips

Text-processing fundamentals worth knowing

Tokenise with Unicode classes

Use \p{L}\p{N} with the u flag so accents, ideographs, and emoji count properly.

Normalise line endings

Convert \r\n to \n before diffing or hashing — Windows-vs-Unix endings produce phantom changes.

Mind invisible characters

Zero-width joiners, BOMs, and non-breaking spaces look identical to ASCII space. Strip them before comparison or storage.

Stream don’t slurp

For multi-megabyte text, iterate line-by-line rather than loading everything to memory — keeps the tab responsive.

Choose collation deliberately

Default JS sort is code-point order, not human alphabetical. Use Intl.Collator for locale-aware sorting.

Re-run after normalisation

NFC vs NFD changes byte length but not visible glyphs. String.prototype.normalize() before counts and comparisons.

Use Cases

When to convert tabs ↔ spaces

Anywhere indentation conventions matter.

Python source

PEP 8 wants 4 spaces, no tabs. Convert before committing. Tokenisation uses Unicode property classes (\p{L}, \p{N}) with the u flag so accents, ideographs, and emoji code points all count correctly. Surrogate-pair-aware counts mean 🚀 weighs 1, not 2.

PEP 8-friendly

Go source

Go prefers tabs. Convert when importing from a spaces codebase. Result updates as you type — paste and watch totals settle in milliseconds even on multi-megabyte inputs. Heavy work runs through a memoised reducer so the editor never janks.

diff-clean

Markdown code

MD code blocks often want 4 spaces (not tabs). Output normalises line endings to LF for clean diffs across platforms. Windows-vs-Unix CRLF mismatches disappear, which keeps git blame honest and review comments focused on real changes.

instant counts

Makefiles

Makefiles REQUIRE tabs for recipes — convert from spaces. Code-point counts are stable across NFC/NFD normalisation. Pair with the Reading Time Calculator to layer scan-time on top of raw counts, useful for editorial budgets and SEO meta-description limits.

platform-aware

YAML normalize

YAML forbids tabs for indentation — convert before linting. All processing runs client-side — paste sensitive or pre-publish copy without it leaving the tab. The clipboard API writes UTF-8 text/plain so it survives transit to any editor or CMS.

code-point-accurate

Editor migration

Move code between editors with different defaults. Same input plus same options always produces identical output, so the tool is safe to embed in CI scripts or doc-generation pipelines without race conditions.

lossless
FAQ

Frequently asked questions

Leading-only is safer — it touches just the indentation. 'All' rewrites tabs/spaces everywhere including inside string literals.
2 (JS/HTML), 4 (Python), 8 (Linux kernel). Pick what your project uses.
The tool still processes them; consider running through a linter (Prettier, gofmt) for guaranteed canonical output.
No. All processing runs locally.
No — only the leading or all tabs/spaces. CR/LF are unchanged.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!