Skip to content

zegulas/remove-invisible-characters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Invisible Characters Remover

🧼 A lightweight utility to clean up strings by removing a wide range of invisible and non-printable characters in JavaScript.

✨ Features

  • Removes characters such as NULL, Backspace, Line Feed, No-Break Space, and many more (ASCII 0–31, \xA0).
  • Helps clean up corrupted input, malformed text from external sources, or unintentional invisible characters.
  • Pure function – no dependencies, easy to test and integrate.

πŸ“¦ Installation

You can use this utility in two ways:

Option 1: Copy File Directly

Download removeInvisibleCharacters.js and import it into your project.

Option 2: Via NPM (if published)

npm install remove-invisible-characters

πŸš€ Usage

const { removeInvisibleCharacters } = require('remove-invisible-characters');

const original = "Hello\x00World\xA0!";
const cleaned = removeInvisibleCharacters(original);

console.log(cleaned); // "Hello World !"

πŸ§ͺ What It Removes

It targets and replaces the following ASCII characters with a single space:

  • Control characters: \x00 to \x1F
  • Non-breaking space: \xA0

This ensures the resulting text is clean, visible, and safe for further processing or display.

πŸ“„ API

removeInvisibleCharacters(text: string): string

Parameters:

  • text – A string that may contain invisible characters.

Returns:

  • A new string with all targeted invisible characters replaced with spaces.

πŸ“œ License

MIT – Free to use, modify, and distribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •