emojis-cleaner β€” A npm package to remove Emojis from Any File or Codebase (CLI + JS API)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyrinNew
    Senior Member
    • Feb 2024
    • 5175

    #1

    emojis-cleaner β€” A npm package to remove Emojis from Any File or Codebase (CLI + JS API)

    Introducing emojis-cleaner β€” Remove Emojis from Any File or Codebase (CLI + JS API)

    Have you ever opened a file in your codebase and found random emojis inside comments, logs, commits, or strings?


    Yes, they look aesthetic… until they break your CI, minifiers, builds, or linters. πŸ˜…


    I ran into this too many times and decided to fix it once and for all.


    So today, I'm excited to introduce:





    emojis-cleaner β€” a simple tool to remove all emojis from any project

    NPM: https://www.npmjs.com/package/emojis-cleaner


    emojis-cleaner is a tiny Node.js package + CLI tool that:


    βœ” Removes all emojis from any text

    βœ” Works on any file type (JS, TS, HTML, JSON, Markdown, etc.)

    βœ” Can clean entire folders recursively

    βœ” Automatically ignores node_modules

    βœ” Can also be used directly in JS code


    Whether you want to sanitize logs, clean content, or enforce β€œno emojis in code”, this tool does the job.



    Installation

    Global (use as CLI)




    npm install -g emojis-cleaner





    Local




    npm install emojis-cleaner







    Usage (CLI)

    Clean all emojis from a folder




    emojis-cleaner .





    Clean emojis from a specific file




    emojis-cleaner src/index.js





    Example Output




    Cleaned: src/app.js
    Cleaned: src/utils/logs.js
    Cleaned: README.md
    Emoji removal complete!






    The CLI scans everything recursively, removes emojis, and updates files in place.



    🧠 Use as a Function (Node.js API)

    You can also use the same logic inside your Node scripts:






    const removeEmojis = require("emojis-cleaner");

    console.log(removeEmojis("Hello πŸ˜„ World πŸš€"));
    // Output: "Hello World "







    This uses a reliable Unicode regex to detect all emojis, including:
    • basic emojis πŸ˜„
    • flags πŸ³οΈβ€πŸŒˆ
    • symbols ✨
    • multi-emoji clusters πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦
    • skin tones πŸ‘πŸ½





    Why I Built This

    I was working on a project where random emojis were added in:
    • Git commit messages
    • Code comments
    • Debug logs
    • JSON configuration files
    • Markdown docs


    They looked harmless, but:
    • Git diffs broke
    • Some emojis caused UTF-8 build issues
    • Minifiers crashed
    • CI complained about β€œinvalid character 0xF0”


    I searched for a tool that simply scans everything and removes emojis, but couldn’t find one that:
    • worked on any file
    • didn't force me to set configs
    • didn’t require regex tweaking
    • didn’t fail on multi-emoji clusters


    So… I built it πŸ˜„





    πŸ› οΈ How It Works (Internally)

    The CLI:

    1. Resolves the input path
    2. Recursively scans all files
    3. Skips node_modules automatically
    4. Reads each file as UTF-8
    5. Uses a Unicode property regex:




    const emojiRegex = /\p{Extended_Pictographic}/gu;






    1. Rewrites the file without emojis


    The API:






    function removeEmojis(str) {
    return str.replace(emojiRegex, "");
    }







    Simple, predictable, effective.





    Roadmap / Future Features

    Planned improvements:
    • --dry-run mode
    • --stats to show how many emojis were removed
    • Backup mode (--backup)
    • Exclusion patterns (--ignore *.md)
    • VS Code extension
    • Pre-commit hook examples


    If you want any specific feature, drop a comment!





    Final Thoughts

    emojis-cleaner is intentionally small and focused β€” a β€œjust remove emojis” utility that works out of the box.


    If your project needs clean logs, consistent file formats, or emoji-free CI pipelines, this tool can help keep things tidy.


    Try it here: https://www.npmjs.com/package/emojis-cleaner


    If you’d like to contribute, suggest new features, or request enhancements, feel free to comment or open a PR.

    Thanks for reading!







    More...
Working...