Characters not allowed in file names — the full list

Igor R.

September 21, 2026

Short answer: Windows blocks nine characters in file and folder names — < > : " / \ | ? * — plus all control characters. macOS blocks only the forward slash. Linux blocks the forward slash and the null byte. If you need something that looks like a colon or a slash, a Unicode lookalike will pass, with one important caveat further down.

Tap to copy

Pasted a filename that still won’t save? Run the suspect character through the Symbol Identifier — invisible characters are a common culprit.

The nine Windows blocks

CharNameCode pointWhy it’s reserved
<Less-than signU+003CInput redirection in the shell
>Greater-than signU+003EOutput redirection
:ColonU+003ADrive letter separator (C:) and alternate data streams
“Quotation markU+0022Wraps paths containing spaces
/SolidusU+002FPath separator on every other system, and a switch character in DOS
\Reverse solidusU+005CThe Windows path separator itself
|Vertical lineU+007CPipe operator
?Question markU+003FSingle-character wildcard
*AsteriskU+002AMulti-character wildcard

Every one of them is blocked because the shell or the filesystem already uses it for something. There’s no arbitrary blacklist here — each character has a job. The backslash and pipe have their own guides if you want the wider story.

Windows also rejects control characters — code points U+0000 to U+001F. You won’t type those deliberately, but they arrive with text pasted out of spreadsheets and databases more often than you’d expect.

Windows error showing which characters a file name cannot contain

The rules that aren’t about characters

These catch people out far more often, because the error message rarely explains itself.

Reserved device names. Windows still reserves a set of legacy DOS device names, and they’re blocked with or without an extension. CON, PRN, AUX, NUL, COM1 through COM9, and LPT1 through LPT9 are all unusable — so CON.txt fails as surely as CON. The matching is case-insensitive. If you’ve ever had a file called AUX.docx refuse to save, that’s why.

No trailing period or space. report. and report are both rejected. Windows silently strips them in some contexts, which is worse than a clear error, because a file you thought you named one thing is now named another.

Path length. The classic Windows limit is 260 characters for the whole path, not the filename. Deeply nested folders hit it long before any individual name looks unreasonable.

macOS and Linux are far more relaxed

  • macOS blocks only the forward slash. Colons are best avoided — the classic Mac filesystem used : as its path separator, and the legacy shows up in odd places — but almost everything else is legal, including spaces, asterisks and question marks.
  • Linux blocks exactly two things: the forward slash and the null byte. Everything else is technically valid, including newlines and control characters, which is a genuine security consideration rather than a convenience. See typing symbols on Linux.

This asymmetry is the real source of trouble. A file named Q3: results*.xlsx saves happily on a Mac and becomes unopenable the moment it reaches a Windows machine or a sync client.

OneDrive, SharePoint and Google Drive

Cloud sync applies its own layer on top, and it’s stricter than any single operating system because it has to satisfy all of them.

OneDrive and SharePoint block the same nine characters, and add:

  • Leading and trailing spaces in file or folder names.
  • Reserved names: .lock, CON, PRN, AUX, NUL, COM0–COM9, LPT0–LPT9, _vti_, desktop.ini, and anything starting with ~$.
  • Folder names beginning with ~ in SharePoint.
  • A path limit of 400 characters, which sounds generous until a synced folder tree eats most of it.

Microsoft has relaxed some of these over time — # and % were once blocked and now aren’t — so if you’re troubleshooting an old rule, check the current support page rather than an old forum answer.

Google Drive is the permissive one: names are largely unrestricted, including slashes, because Drive doesn’t use a filesystem path model. The catch arrives on download, when a name Drive accepted becomes illegal on the local disk.

Legal lookalikes that pass

When you actually want Q3: results as a name, there’s a Unicode character that looks like a colon and isn’t one. These all pass on every platform:

You wantedUseNameCode point
:꞉Modifier letter colonU+A789
/∕Division slashU+2215
/⁄Fraction slashU+2044
??Fullwidth question markU+FF1F
**Fullwidth asteriskU+FF0A
||Fullwidth vertical lineU+FF5C
<<Fullwidth less-than signU+FF1C
>>Fullwidth greater-than signU+FF1E
“”Right double quotation markU+201D

The caveat matters. These are different characters, not disguised versions of the originals. A search for Q3: results will not find Q3꞉ results. Scripts that match on a colon will skip the file. Sorting places them elsewhere. And the fullwidth forms are visually wider than the ASCII ones, so they look slightly off in a list.

Use them for names a human reads. Don’t use them in anything a program parses. The same reasoning applies to straight vs curly quotes, where a substitution that looks harmless changes what the text actually is.

The invisible ones

A filename that refuses to save while looking completely normal almost always contains something you can’t see:

  • A trailing space, stripped by Windows and preserved by macOS, so the same file has two different names on two machines.
  • A non-breaking space (U+00A0) pasted from a web page or Word. It looks exactly like a space and sorts differently.
  • A zero-width space (U+200B) from a copied web title.
  • Control characters from spreadsheet exports.

Invisible characters covers how to spot them. The quickest check is to paste the name into the Symbol Identifier, which names every code point in what you pasted.

Cleaning names in code

Strip rather than substitute, unless you have a reason to preserve the shape:

javascript

const safe = name => name
  .replace(/[<>:"/\\|?*\u0000-\u001F]/g, "-")   // the nine + control chars
  .replace(/[. ]+$/, "")                         // no trailing dot or space
  .replace(/^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(\.|$)/i, "_$1$2")
  .slice(0, 200);

In PowerShell, the blocked set is available directly rather than hardcoded:

powershell

$invalid = [IO.Path]::GetInvalidFileNameChars()
Get-ChildItem -Recurse | Where-Object { $_.Name.IndexOfAny($invalid) -ge 0 }

Note the reserved-name line in the JavaScript: checking only for blocked characters is the common bug, and it’s the one that lets CON.txt through to fail later.

Accessibility

Lookalike substitutions change what a screen reader says. ꞉ is announced as “modifier letter colon” rather than as a colon, and the fullwidth forms are announced with “fullwidth” attached — so * reads as “fullwidth asterisk”. In a list of filenames read aloud, that’s noise.

If filenames are shared with colleagues who use assistive technology, plain words beat clever punctuation. Q3 results is better than Q3꞉ results in every way that matters. How screen readers pronounce symbols covers the pattern.

Troubleshooting

ProblemFix
“A file name can’t contain any of the following characters”One of the nine. Check for : in particular — dates and times are the usual source.
File won’t save and the name looks fineTrailing space or period, or an invisible character. Check with the Symbol Identifier.
CON.txt or AUX.docx refuses to saveReserved device name. Blocked with or without an extension. Rename it.
Name works on Mac, breaks on WindowsmacOS blocks only /. Rename before sharing or syncing.
OneDrive won’t sync one fileLeading or trailing space, a reserved name, or a path over 400 characters.
Downloaded a Google Drive file and it renamed itselfDrive allowed a character your local filesystem doesn’t.
Lookalike character breaks a scriptExpected — it’s a different character. Use it only in human-facing names.
Path too long on Windows260-character limit applies to the whole path. Shorten the folder tree, not just the file.

Recap

SituationDo this
Naming for WindowsAvoid `< > : ” / \
Naming for cloud syncAlso avoid leading spaces, ~$, and reserved names
Cross-platform sharingUse the Windows rules everywhere — they’re the strictest
You really need a colon꞉ U+A789, for human-facing names only
Writing a sanitiserStrip the nine, trim trailing dot and space, check reserved names
Name fails for no visible reasonPaste it into the Symbol Identifier

Frequently asked questions

Build note: these six go into the Rank Math FAQ block, not into the body as markdown. Do not also paste the JSON-LD appendix from Part 3.

Which characters aren’t allowed in Windows file names? Nine: < > : " / \ | ? *, plus all control characters from U+0000 to U+001F. Each is blocked because the shell or the filesystem already uses it — for redirection, piping, wildcards or path separation.

Why can’t I name a file CON or AUX? They’re legacy DOS device names that Windows still reserves, along with PRN, NUL, COM1–COM9 and LPT1–LPT9. The block applies with or without an extension, so CON.txt fails too, and matching is case-insensitive.

Can I use a colon in a file name? Not on Windows — it separates the drive letter and marks alternate data streams. You can use the modifier letter colon ꞉ (U+A789), which looks nearly identical and is legal everywhere, but it’s a different character and won’t match a search for a real colon.

Why does my file name work on Mac but not Windows? macOS blocks only the forward slash, while Windows blocks nine characters plus reserved names and trailing spaces. A name that’s perfectly legal on a Mac can be impossible to open on Windows.

Why won’t OneDrive sync a file with a normal-looking name? Usually a leading or trailing space, a reserved name such as .lock or desktop.ini, a name starting with ~$, or a path over 400 characters. OneDrive is stricter than Windows alone.

How do I find the invisible character breaking my file name? Paste the name into a Unicode identifier tool, which lists every code point. Non-breaking spaces, zero-width spaces and control characters pasted from web pages or spreadsheets are the usual causes.


Written by Igor R. Tested on Windows 11, macOS, Linux, OneDrive and Google Drive. Last updated September 2026. Symbol code points follow the Unicode Standard.

Leave a Comment