Whitespace is a category, not a single character
In everyday use the word space covers dozens of distinct code points. The Unicode Character Database marks a set of them with the White_Space property, and text specifications such as the WHATWG Infra Standard define a much narrower "ASCII whitespace" set of five characters. A tool, a programming language, and a layout engine can each use a different definition, which is why text can still look wrong after you believe every space has been removed.
Two properties matter for cleanup. The first is visible width: does the character draw a gap, and how wide. The second is line-break behavior: does the character allow, forbid, or force a wrap at that point. The line-breaking algorithm is specified in Unicode Standard Annex #14. A non-breaking space has the width of a normal space but forbids a wrap; a zero-width space has no width but permits one. Knowing both properties tells you whether to convert a character to a plain space or delete it.
Horizontal space characters
These characters separate words or align text within a line. They never start a new line.
| Code point | Name | Width | Wrap | Typical source |
|---|---|---|---|---|
U+0020 | Space | One space | Allowed | The spacebar; almost every text source. |
U+0009 | Character Tabulation (Tab) | To next tab stop | Allowed | Code indentation, TSV files, aligned plain text. |
U+00A0 | No-Break Space (NBSP) | One space | Forbidden | HTML , word processors, pasted web text. |
U+202F | Narrow No-Break Space | Narrow | Forbidden | French punctuation spacing, clock times, some currencies. |
U+2007 | Figure Space | Width of a digit | Forbidden | Padding numbers so columns of figures align. |
U+2009 | Thin Space | Thin | Allowed | Typographic spacing around punctuation and units. |
U+2002 / U+2003 | En Space / Em Space | Half em / one em | Allowed | Typesetting, pasted design or publishing content. |
U+3000 | Ideographic Space | Full width | Allowed | CJK text, full-width form input, indented Asian prose. |
U+00AD | Soft Hyphen | Zero unless line breaks | Break opportunity | Word processors and CMS hyphenation; not whitespace, but often found beside it. |
Tab, line-ending, and separator characters
These characters control vertical structure. Removing or converting them changes how many lines the text has.
| Code point | Name | Escape | Typical source |
|---|---|---|---|
U+000A | Line Feed (LF) | \n | Unix, Linux, modern macOS, most programming output. |
U+000D U+000A | Carriage Return + Line Feed (CRLF) | \r\n | Windows text files, HTTP headers, many network formats. |
U+000D | Carriage Return (CR) | \r | Classic Mac OS files, some legacy exports. |
U+000B / U+000C | Vertical Tab / Form Feed | \v / \f | Old print workflows, some PDF and RTF extraction. |
U+0085 | Next Line (NEL) | — | EBCDIC-derived data, some mainframe exports. |
U+2028 / U+2029 | Line Separator / Paragraph Separator | — | Text copied from design tools; can break JavaScript string parsing. |
Zero-width and invisible format characters
These characters usually draw nothing. They are grouped with whitespace during diagnosis because they make two identical-looking strings behave differently, but several of them carry meaning and should not be deleted blindly.
| Code point | Name | Purpose | Safe to delete? |
|---|---|---|---|
U+200B | Zero Width Space | Marks a wrap opportunity without drawing a gap. | Usually yes in plain data; review long words and URLs. |
U+FEFF | Byte Order Mark / Zero Width No-Break Space | Encoding signature at the start of a file; legacy no-break joiner mid-text. | Yes at the start of a file; check context mid-text. |
U+2060 | Word Joiner | Forbids a wrap with no width; modern replacement for a mid-text BOM. | Only if wrapping at that point is acceptable. |
U+200C | Zero Width Non-Joiner (ZWNJ) | Prevents letters from forming a ligature or joined form. | No in Persian, Arabic, Indic scripts; changes spelling. |
U+200D | Zero Width Joiner (ZWJ) | Forces a joined form; builds many combined emoji. | No; can break emoji and script rendering. |
Because of the last two rows, a careful invisible-character cleanup separates U+200B and a stray U+FEFF, which are usually residue, from ZWNJ and ZWJ, which are usually intentional. The zero-width character remover offers a cautious mode that keeps the joining controls.
How these characters reach your text
- PDF extraction preserves typographic spaces (thin, figure, narrow no-break) and inserts a line ending at every visual row, plus occasional form feeds between pages.
- HTML and the web turn
into U+00A0, and copying rendered text keeps the Unicode character rather than the entity, as covered in the WHATWG named character reference. - Word processors auto-insert protected spacing around initials, units, and punctuation, and add soft hyphens during hyphenation.
- Spreadsheets export CRLF line endings and can leave a leading BOM in the first cell of a CSV.
- Chat and design tools sometimes emit U+2028 or zero-width characters that survive a copy and paste.
- Input methods for CJK languages can produce full-width U+3000 instead of an ASCII space.
A detection checklist
- A short phrase overflows the right edge and never wraps: suspect
U+00A0orU+202F. - An exact-match search or a database join fails on text that looks identical: suspect
U+200B,U+FEFF, or a trailing regular space. - Columns line up in one program and collapse in another: suspect
U+0009tabs. - Every sentence sits on its own line: suspect hard
LForCRLFfrom a PDF or wrapped email. - A script or parser throws an "unexpected token" or "unterminated string": suspect
U+2028orU+2029. - To confirm, paste a small sample into a tool here and read the live audit, or in a console run
JSON.stringify(text)and inspect the\uXXXXescapes.
Which tool removes which character
| Characters | Tool |
|---|---|
Repeated U+0020, tabs, and mixed Unicode spaces in a line | Remove Spaces |
U+00A0, U+202F, U+2007 | Remove Non-Breaking Spaces |
U+200B, U+200C, U+200D, U+2060, U+FEFF | Remove Zero-Width Characters |
U+0009 tabs (remove or expand) | Remove or Expand Tabs |
LF, CRLF, CR between content lines | Remove Line Breaks |
| Whitespace-only lines | Remove Empty Lines |
| Leading and trailing whitespace on each line | Trim Lines |
For behavior-focused explanations rather than a character list, see the Unicode whitespace guide and Non Breaking Space. To compare this approach with writing code, read Browser Tool Versus Code Methods.