Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

show-invisibles

🕵️‍♂️ Reveal and clean invisible Unicode characters from text — both as a CLI and a library.

Purpose

Invisible characters like zero-width spaces (U+200B), byte-order marks, or directionality markers can sneak into text files, source code, or user input — often causing frustrating bugs or unexpected behavior.

show-invisibles helps you:

  • ✅ Identify and make invisible characters visible in your text.
  • 🧹 Clean unwanted or problematic characters.
  • ⚒️ Customize how these characters are shown or replaced.
  • 🧪 Use as a CLI tool or integrate as a Node.js library.

Features

  • Supports a wide range of invisible and control characters.
  • Offers two main operations:
    • mark: Replaces invisible characters with visible placeholders.
    • clean: Removes or replaces problematic invisible characters.
  • Customizable format for marked output: %u (unicode), %n (name), or your own syntax.
  • --all flag to show even standard control characters (like \n, \t, \r).
  • Emits statistics to stderr (characters found and/or replaced).
  • ES Modules support and typings included.

Installation

npm install -g show-invisibles

Or use locally in a Node project:

npm install show-invisibles

CLI Usage

show-invisibles [file|-] [options]

Options

Flag Description
--clean Remove or replace invisible characters (instead of marking them).
--all Include common control characters like \n, \r, \t.
--format Format string for replacements (default: [%u]).
--help Show usage help.

Format String

You can use custom format strings for how invisible characters are displayed:

  • %u – Unicode code point (e.g. U+200B)
  • %n – Character name (e.g. ZERO_WIDTH_SPACE)
  • %% – Literal %

Examples:

# Reveal all invisible characters with default format
cat suspicious.txt | show-invisibles

# Clean all invisibles in a file
show-invisibles --clean suspicious.txt

# Show control chars too, use name instead of code
show-invisibles some.txt --all --format="[%n]"

# Use custom format
show-invisibles --format="!!%u!!" some.txt

Library Usage

import {
  markInvisibles,
  cleanInvisibles,
  formatReplacement,
} from 'show-invisibles'

const input = 'Some\u200Btext'
const { result, count } = markInvisibles(input, false, '[%n]')
// result => 'Some[ZERO_WIDTH_SPACE]text'
// count => 1

const cleaned = cleanInvisibles(input)
// cleaned.result => 'Sometext'
// cleaned.count => 1

Supported Characters

Includes:

  • Zero-width characters (U+200B, U+200C, etc.)
  • Directionality markers (U+202AU+202E, U+2066U+2069)
  • Byte Order Mark (U+FEFF)
  • Figure space (U+2007)
  • Control characters (optional): \n, \r, \t, \f, etc.

Development

Build

npm run build

Run tests

npm test

License

MIT © 2025

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages