Skip to main content

Hidden Characters

Remove Invisible Characters from Text

By Issaaf Kattan · Updated

Paste your text to clean it

Your text

No text handy? Try:

Cleaned text

Your text never leaves this browser. How we know

Same words · No AI rewriting · No content logging

Why are there invisible characters in my text?

Invisible characters creep into text whenever you copy from PDFs, web pages, Word, Excel — or AI chatbots like ChatGPT. Characters such as the zero-width space (U+200B), soft hyphen (U+00AD), and bidirectional control marks have no visible glyph, but they are real characters to every computer program. They break search, spellcheck, code, and formatting the moment you paste them somewhere new.

Most were designed for typesetting — telling a layout engine where it may break a long word, or which direction mixed Arabic/English text should flow. Outside that context they are pure baggage: they make "helloworld" unfindable in search, trip up markdown parsers, and trigger mysterious syntax errors in code. The direction-switching family is the most consequential of the group, because it can make source code read differently to a human than it does to a compiler — it has its own guide on how to remove BiDi control characters.

Common invisible characters this tool removes

U+200B

Zero Width Space (ZWSP)

Marks a potential word boundary. Invisibly joins words, breaking search and spellcheck.

It has legitimate uses in languages that don't use visible spaces, like Thai or Japanese. Elsewhere, a U+200B between "hello" and "world" makes "helloworld" eleven characters, not ten: searching for the word fails, and it can wrap mid-word. In code, Node reports "SyntaxError: Invalid or unexpected token", while CPython names the character — "SyntaxError: invalid non-printable character U+200B".

U+FEFF

Byte Order Mark (BOM)

A file-encoding marker that shows up as a ghost character when pasted into web apps.

U+200E / U+200F

Directional Marks (LRM/RLM)

Switch text direction between left-to-right and right-to-left. Cause cursor glitches and flipped punctuation.

U+00AD

Soft Hyphen

An invisible hyphenation hint from PDFs and justified layouts that pollutes plain text.

It shows as a hyphen only if the line actually breaks there. Web pages write it as ­, and Word inserts one when you press Ctrl and minus. Delete it rather than replacing it with a hyphen, which would add a visible hyphen to words that were never split; in Excel, =SUBSTITUTE(A1, UNICHAR(173), ""). Keep it only in HTML or Word source you are still going to publish.

U+2060

Word Joiner

Prevents line breaks without any visible width — a frequent stowaway in copied text.

U+202F

Narrow No-Break Space

A thin, non-breaking space, known for a brief April 2025 appearance in o3 and o4-mini output — nearly indistinguishable from a normal space.

U+202F is the character at the centre of the ChatGPT watermark characters story. For the complete table of every character we detect — including Unicode tag characters and variation selectors — see the full invisible Unicode characters list.

Remove one specific invisible character

Each character behaves differently and has a different safe way to remove it. Start from the one you found:

Or start from where the text came from: PDF, Word, Google Docs or Outlook, Excel, or an AI chatbot such as ChatGPT, Copilot or Perplexity.

Why a cleaner beats find-and-replace

Paste into the box above and the report names each hidden character it removed. Unlike find-and-replace, the cleaner targets the specific Unicode ranges assigned to format and control characters, so it catches variants you'd never think to search for — while leaving legitimate characters (including emoji and non-Latin scripts) intact in the default preset. Non-breaking spaces are a slightly different case — they are real, visible-width spaces rather than zero-width ones — and the non-breaking space remover covers U+00A0 and its narrow U+202F relative in detail.

Regex to remove invisible characters (JavaScript and Python)

Zero-width spaces, word joiners, byte order marks, soft hyphens, and bidirectional controls share one Unicode general category, Cf ("Format"), so a single property escape targets the whole group:

function stripInvisible(text) {
  return text
    // Cf: zero-width space/joiner, BOM, soft hyphen, bidi controls, tag
    // characters — except ZWNJ/ZWJ, which change spelling in some scripts.
    .replace(/\p{Cf}/gu, (ch) => (ch === "\u200C" || ch === "\u200D" ? ch : ""))
    // Zs: fold exotic Unicode spaces to a plain one instead of deleting them.
    .replace(/\p{Zs}/gu, (ch) => (ch === " " ? ch : " "));
}

The u flag is required: without it, \p{Cf} silently matches the literal text p{Cf} and no invisible character. \s is no substitute, because it matches whitespace and a zero-width space (U+200B) or word joiner (U+2060) is a format character, not whitespace. JavaScript's \s happens to include the non-breaking space (U+00A0) and the byte order mark (U+FEFF), which is why those two seem to get cleaned up for free. Python's \s matches U+00A0 but not U+FEFF, so a byte order mark survives a Python whitespace strip.

Python's built-in re module has no \p{...} syntax (it raises re.error: bad escape \p), so filter by category with the standard library, or install the third-party regex package, which accepts the same \p{Cf} syntax as JavaScript:

import unicodedata

def strip_invisible(text: str) -> str:
    keep_anyway = "\u200c\u200d\t\n\r"  # ZWNJ, ZWJ, and real whitespace
    return "".join(
        ch for ch in text
        if unicodedata.category(ch) not in ("Cf", "Cc") or ch in keep_anyway
    )

A Cf/Zs pattern still misses two groups, so it can report clean text that still carries a payload: variation selectors (U+FE00–U+FE0F, U+E0100–U+E01EF), which are category Mn and the channel used to smuggle hidden bytes onto a character or emoji, and C0/C1 control characters (category Cc).

Before cleaning code, JSON, or CSV, keep the original input. Detect before you normalize: the cleaner above scans the untouched input first, so a U+202F or U+FEFF still shows in the report even if a later pass folds or removes it. Then choose a policy for the destination, not the source: Plain ASCII only where the target permits nothing else, join controls kept in multilingual text, and the destination's own parser or tests as the final check.

Common questions

Frequently asked questions

How do I remove invisible characters from text?

Paste the text into a Unicode cleaner like CleanPastedText. It scans every code point, counts hidden characters such as zero-width spaces (U+200B), byte order marks (U+FEFF), and soft hyphens (U+00AD), and returns the same text with those characters stripped. Manual removal isn't practical because the characters have no visible glyph.

How do I remove zero-width characters from text?

Paste the text into CleanPastedText and copy the result. It removes the zero-width family: the zero-width space (U+200B), word joiner (U+2060), and the zero-width joiner and non-joiner (U+200D, U+200C; kept inside emoji, but turn off Joiners in Advanced controls for Persian or Indic text that needs them). In code, a pattern such as [\u200B\u2060\uFEFF] with a global replace covers the common ones.

How do I remove invisible characters from AI text?

Paste the AI output into the cleaner. It strips hidden characters that arrive through the chat page, Word or PDF copy, and reports each one by name. It does not touch statistical watermarks or change AI detector scores.

Why does my text contain invisible characters?

They usually arrive via copy-paste from web pages, PDFs, Word, Excel, or AI chatbots like ChatGPT. Layout engines and generators insert zero-width spaces, non-breaking spaces, and soft hyphens for line-breaking control, and those characters travel with the text when you copy it.

Can invisible characters break my code?

Yes. A zero-width space or BiDi control character inside source code can cause syntax errors, failed string comparisons, or misleading code review diffs — the 'Trojan Source' class of bugs. Cleaning pasted snippets before committing them avoids this.

Is it safe to paste sensitive text into this tool?

Yes. CleanPastedText is 100% client-side JavaScript: the text is processed in your browser's memory and never uploaded, logged, or stored. You can even load the page, disconnect from the internet, and keep using it.

Does ChatGPT put invisible characters in its answers?

Not deliberately, as far as anyone has documented; the one clear episode was a brief U+202F appearance in o3 and o4-mini output in April 2025. Our November 2026 copy test found none in text copied straight from ChatGPT; they reach AI drafts through Word, Docs, PDF and email copy pipelines, and a remover strips every format and control character it detects.

Continue reading

Related guides & tools