· 5 min read
How to Find Hidden Characters Lurking in Pasted Text
Heshan Fernando
Co-founder & COO
A username field rejects “duplicate” input that looks completely different from the existing one on screen. A form validation script chokes on a string that looks empty but isn’t. A block of text pasted from a website behaves strangely in a script — extra spacing that won’t go away no matter how many times you delete and retype it. Nine times out of ten, the culprit is an invisible Unicode character sitting in the text where you can’t see it: a zero-width space, a non-breaking space, a byte-order mark, or something similar.
These characters are invisible by design — that’s the point of a zero-width space or a non-breaking space — but “invisible” doesn’t mean “harmless.” They still count as characters to a string comparison, a form validator, or a length check, which is exactly how they cause bugs that are maddening to track down because the text looks completely normal.
What invisible characters actually are
Unicode includes a category of characters that render as nothing, or as ordinary-looking whitespace, but are distinct code points from a regular space or newline. A zero-width space (U+200B) is used to suggest a break point in a long word without rendering anything visible. A non-breaking space (U+00A0) looks like a regular space but prevents line wrapping at that point — common in text copied from websites that don’t want a number and its unit to split across lines. There are others: zero-width joiners, byte-order marks, various Unicode format characters. None of them are inherently malicious; most exist for legitimate typographic reasons. The problem is when they end up somewhere you didn’t intend, silently changing what a string actually contains.
Why people get stuck here
- They’re invisible by definition. You can’t spot a zero-width space by reading the text on screen — it renders as literally nothing.
- Copy-paste is the usual source. Text copied from a web page, a PDF, or a rich-text editor frequently carries invisible formatting characters along with the visible text.
- They break exact-match logic. A username, coupon code, or form field that looks identical to what’s expected can still fail a strict equality check if one has a hidden character the other doesn’t.
- Standard find-and-replace doesn’t help. You can’t search for a character in a text editor if you don’t know it’s there, and most invisible characters don’t have an obvious keyboard shortcut to type or search for.
What a useful invisible character tool looks like
Detects what’s actually in your text
Paste a block of text and get a report of exactly which invisible or unusual characters are present and where, rather than a generic “something’s wrong” message.
Lets you copy specific characters on purpose
Sometimes you want a zero-width space or non-breaking space deliberately — to hint at a word break, or to keep a number and unit together on one line. Having a reliable way to copy the exact character, rather than hunting for it in a Unicode chart, saves time.
Doesn’t just strip everything blindly
A good tool distinguishes between characters that are probably a mistake and ones that might be intentional, rather than deleting all non-ASCII content indiscriminately.
Common mistakes to avoid
- Assuming a form validation bug is a logic error in your code before checking whether the input string actually contains an invisible character.
- Copy-pasting text from a website into a form or script without checking for hidden characters, especially for anything that needs an exact match (codes, usernames, IDs).
- Deleting and retyping text to “fix” an invisible character issue, which usually doesn’t work if the character is coming from the source you’re copying from again.
- Using a blunt regex to strip all non-printable characters without checking whether some of them (like a legitimate non-breaking space) were actually intentional.
- Not checking for a byte-order mark (BOM) at the start of a file when text imported from one system behaves oddly in another.
How to do it with Invisible Character Tool
Online Tool Store’s Invisible Character Tool runs in your browser — pasted text is never uploaded anywhere.
- Open the Invisible Character Tool.
- Paste the text you suspect has a hidden character issue.
- Review the detected invisible or unusual characters and where they appear in the text.
- Separately, use the tool to copy a specific invisible character (like a zero-width space or non-breaking space) when you need one intentionally.
Because it’s local, it’s safe to use on text you wouldn’t want to paste into an unfamiliar third-party site — usernames, codes, or anything from an internal system.
Frequently asked questions
Why does my form say two identical-looking strings don’t match?
The most likely cause is an invisible character in one of the strings — a zero-width space, non-breaking space, or similar — that makes them different at the character level even though they render identically. A detector will show you exactly which character and where.
Are invisible characters always a problem?
No. Many exist for legitimate reasons — a non-breaking space keeps “10 km” from wrapping mid-unit, and a zero-width space can hint at a break point in a long unbroken word. They only become a problem when they end up somewhere unintended, like inside a code or username field.
Can copy-pasting from a website introduce these characters without me noticing?
Yes, this is the most common source. Rich text from web pages, PDFs, and some word processors frequently carries formatting characters like non-breaking spaces or zero-width joiners along with the visible text, and pasting as plain text doesn’t always strip all of them.
Final thought
Invisible characters cause some of the most frustrating bugs precisely because there’s nothing to see — the fix only becomes obvious once you can actually detect what’s there. Keep a detector in your back pocket for the next time a string comparison fails for no visible reason.