Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Nifty Whitespace: Indent Rainbow, Invisible Characters & TrimNew to Visual Studio Code? Get it now.
Nifty Whitespace: Indent Rainbow, Invisible Characters & Trim

Nifty Whitespace: Indent Rainbow, Invisible Characters & Trim

Nifty

|
1 install
| (0) | Free
Indent rainbow, invisible and confusable characters with quick fixes, mixed line endings and tabs, and trimming trailing whitespace only on the lines you changed.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Nifty Whitespace

Indent rainbow, invisible and confusable characters with quick fixes, mixed line endings and tabs, and trimming trailing whitespace only on the lines you changed.

Maintained. No sign-in. No telemetry. Works in VS Code, Cursor, Windsurf, VSCodium and other editors that use Open VSX.

Features

A Python file with each indentation level in its own colour, a red band where a line is indented by 6 spaces instead of 8, and trailing whitespace highlighted

A Trojan Source comparison: right-to-left override and isolate characters, and a zero-width space in a variable name, labelled in the editor and listed in Problems

The quick fix menu on a zero-width space: remove it, or fix all 5 hidden characters in the file

A shell script with two CRLF line endings among LF ones, marked at the end of those lines, with a warning in the status bar

The Git diff after saving: only the edited line lost its trailing whitespace; other lines with trailing spaces are untouched

  • Trim trailing whitespace only on the lines you changed. On save, lines that differ from the last Git commit and lines you edited since opening the file lose their trailing whitespace. Everything else stays as it was, so a one-line fix stays a one-line diff. Auto save after a delay leaves the line you're typing on alone, and Markdown line breaks (two trailing spaces) are kept. Set trimOnSave to all to trim every line, or off.
  • Indent rainbow. Each indentation level gets its own colour, following the file's tab size. Indentation that isn't a whole number of steps (6 spaces in a 4-space file) and indents that mix tabs and spaces in one line are highlighted. Block comment lines (*) don't count as errors.
  • Invisible and confusable characters. Zero-width spaces and joiners, no-break and other odd spaces, soft hyphens, control characters, byte order marks in the middle of a file, Hangul fillers and invisible Unicode tag characters are labelled where they are (ZWSP, NBSP…). Bidirectional controls that make code read differently from how it runs (Trojan Source) are errors.
  • Look-alikes in code. Curly quotes where code expects straight ones, an em dash used as a flag (—force), full-width punctuation, the Greek question mark that looks like ;, and names that mix Latin with Cyrillic or Greek letters (pаypal with a Cyrillic а). Prose (Markdown, plain text, HTML) is left alone, and emoji sequences and flags aren't flagged.
  • Problems and quick fixes. Each hidden character is listed in Problems with what it is and why it matters. Quick fixes remove it or replace it with its plain look-alike, one at a time, all of the same kind, or all in the file.
  • Mixed line endings. VS Code quietly converts a file with both CRLF and LF to one kind when it opens it. Nifty Whitespace reads the file from disk, marks the lines that differ, warns in Problems and the status bar, and converts the whole file to LF or CRLF in one click. showLineEndings: all shows CRLF/LF at the end of every line.
  • Tabs and spaces in one file. When some lines are indented with tabs and others with spaces, you get a warning with quick fixes to convert the indentation.
  • Scan the workspace for hidden characters with Find Hidden Characters in Workspace, for example before merging a contribution.
  • Fast on big files. Decorations are drawn only for the lines on screen and updated as you scroll or type. Files over 2 million characters skip the whole-file checks.
  • Works in the browser on vscode.dev and github.dev (without Git there, trimming uses the lines you edited).

VS Code highlights some invisible characters itself (editor.unicodeHighlight); Nifty Whitespace adds labels, explanations, Problems entries, quick fixes and a workspace scan.

Commands

Command What it does
Nifty Whitespace: Fix Whitespace… Pick a fix for the current file (also from the status bar)
Nifty Whitespace: Remove Hidden Characters in File Remove or replace every invisible and look-alike character
Nifty Whitespace: Convert Line Endings… Convert every line ending in the file to LF or CRLF
Nifty Whitespace: Trim Trailing Whitespace on Changed Lines Trim now, without saving
Nifty Whitespace: Find Hidden Characters in Workspace Check every text file and list what it finds in Problems

Settings

Setting Default What it does
nifty.whitespace.trimOnSave changedLines changedLines, all or off
nifty.whitespace.keepMarkdownLineBreaks true Keep two trailing spaces in Markdown
nifty.whitespace.indentRainbow true (off in Markdown and plain text) Colour indentation levels
nifty.whitespace.indentColors 4 soft colours Colours for the levels, repeated
nifty.whitespace.indentErrors true Highlight broken and mixed indentation, warn about tabs and spaces in one file
nifty.whitespace.highlightTrailing true Highlight trailing whitespace
nifty.whitespace.invisibleCharacters true Show invisible characters
nifty.whitespace.confusables true Also flag look-alike punctuation and mixed-script names in code
nifty.whitespace.allowedCharacters [] Characters never to flag, e.g. "U+00A0"
nifty.whitespace.showLineEndings mixed mixed marks lines that differ from the rest, all marks every line, or off
nifty.whitespace.problems true List findings in the Problems panel
nifty.whitespace.maxFileSize 2000000 Above this many characters, only what's on screen is checked

Every setting except the colours can be set per language, for example "[python]": { "nifty.whitespace.indentRainbow": false }. The colours of trailing whitespace, indentation errors and hidden characters can be changed in workbench.colorCustomizations (nifty.whitespace.*).

If files.trimTrailingWhitespace is on, VS Code trims every line itself; turn it off to trim only changed lines.

Install

  • VS Code: search for "Nifty Whitespace" in the Extensions view, or install from the Visual Studio Marketplace.
  • Cursor, Windsurf, VSCodium, Kiro, Antigravity: install from Open VSX.

Privacy

This extension collects no telemetry and needs no account.

More Nifty tools

  • Nifty Code Metrics: Complexity & Hotspots: Complexity and size for every function in any language, as CodeLens and warnings, plus a hotspots view of the complex files that change most often. (Open VSX)
  • Nifty JSON: Formatter, Validator & JSONPath: Format, minify, sort keys, query with JSONPath, copy paths, generate TypeScript types, and browse huge JSON files in a fast tree view. (Open VSX)
  • Nifty XML: XPath, Formatter & XML to JSON: Evaluate XPath with namespaces, copy the XPath of any element, format, minify, check well-formedness and convert XML to JSON. (Open VSX)
  • Nifty YAML: Formatter, Validator & Converter: Format YAML without losing comments (Kubernetes-style indents), sort keys, lint with yamllint, copy the key path, and convert to and from JSON. (Open VSX)
  • Nifty Beautify: Format HTML in PHP, Blade & Twig: Format HTML inside PHP, Blade, Twig, Jinja, Handlebars, ERB and Liquid templates without breaking the template tags. (Open VSX)
  • Nifty Colors: Swatches & Picker in Every Language: Colour swatches and VS Code's picker in any file: CSS, Tailwind, Flutter, Swift, Android, C# and Unity colours. Convert formats and check WCAG contrast on hover. (Open VSX)

See all 56 Nifty tools at https://getnifty.dev

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft