npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

text-sanctifier

v1.0.16

Published

A brutal text normalizer and invisible trash scrubber for modern web projects.

Downloads

13

Readme

text-sanctifier

npm gzip size downloads GitHub stars

Brutal text normalizer and invisible trash scrubber for modern web projects.

  • Minified: (3.09 KB)
  • Gzipped (GCC): (1.36 KB)

Features

  • Purges zero-width Unicode garbage
  • Normalizes line endings (CRLF, CR, LF) → LF
  • Collapses unwanted spaces and paragraphs
  • Nukes control characters (if enabled)
  • Smart normalization of typographic junk (quotes, dashes, bullets, full-width punctuation)
  • Keyboard-only filtering (retain printable ASCII + emoji, or restrict)
  • Configurable via fine-grained flags or ready-made presets
  • Includes strict, loose, and keyboard-only modes

Install

npm install text-sanctifier

📦 Package & Build Info

  • Source (src/): ES2020+ ESM modules with JSDoc
  • Browser Build (dist/): Minified ESM bundle for <script type="module">
  • Tree-shaking Friendly: Fully optimized with sideEffects: false
  • Zero Transpilation: No built-in polyfills or runtime overhead
  • Bundler Ready: Works great with Vite, Rollup, Webpack, Parcel, etc.

🔧 Quick Usage

Custom Config

import { summonSanctifier } from 'text-sanctifier';

const clean = summonSanctifier({
  purgeInvisibleChars: true,
  purgeEmojis: true,
  collapseSpaces: true,
  collapseNewLines: true,
  preserveParagraphs: true,
  finalTrim: true,
});

const output = clean(rawText);

Strict Preset

const output = summonSanctifier.strict(rawText);

Loose Preset

const output = summonSanctifier.loose(rawText);

Keyboard-Only (No Emojis)

const output = summonSanctifier.keyboardOnly(userInput);

Keyboard-Only (With Emojis)

const output = summonSanctifier.keyboardOnlyEmoji(commentText);

🔍 Unicode Trash Detection

import { inspectText } from 'text-sanctifier';

const report = inspectText(input);

/*
{
  hasControlChars: true,
  hasInvisibleChars: true,
  hasMixedNewlines: false,
  newlineStyle: 'LF',
  hasEmojis: true,
  hasNonKeyboardChars: false,
  summary: [
    'Control characters detected.',
    'Invisible Unicode characters detected.',
    'Emojis detected.',
    'Consistent newline style: LF'
  ]
}
*/

Use inspectText to preflight text content before rendering, storing, or linting. It's a diagnostic tool to help inform sanitization needs.

Pass the report to getRecommendedSanctifierOptions(report) to auto-generate config flags for summonSanctifier().


API

summonSanctifier(options?: SanctifyOptions): (text: string) => string

Creates a reusable sanitizer from an option object.

summonSanctifier.strict

Aggressively purges: emojis, control characters, extra spacing, and newlines.

summonSanctifier.loose

Gently normalizes spacing and newlines while preserving emojis and paragraphs.

summonSanctifier.keyboardOnly

Restricts to printable ASCII only (removes emojis).

summonSanctifier.keyboardOnlyEmoji

Restricts to keyboard-safe ASCII + emojis. Preserves fun, removes weird.

inspectText(text: string): UnicodeTrashReport

Returns a structural report of control codes, invisible chars, newline styles, and more.


License

--{DR.WATT v3.0}--