Every rule that governs what SharePoint Online will and will not accept as a file or folder name, in one place.
| Restriction category | Rule | Impact if violated |
|---|---|---|
| Blocked characters | " * : < > ? / \ | # % |
Upload or create operation fails with an error. File cannot be saved to SharePoint with these characters in the name. |
| Leading / trailing spaces | File and folder names cannot begin or end with a space character. | SharePoint strips leading and trailing spaces silently in some contexts; in others, SharePoint rejects the upload. Migration tools may fail or produce mismatched file names. |
| Trailing period | File and folder names cannot end with a period (.). |
Upload fails. Windows file systems also block trailing-period names, so this typically affects files originating from non-Windows systems or scripts. |
| Leading tilde | File names cannot begin with a tilde (~). |
Reserved for Office temporary files. SharePoint rejects uploads of files whose names start with tilde. |
| Windows reserved names | CON PRN AUX NUL COM1-COM9 LPT1-LPT9 (with or without a file extension) |
These device names are reserved by Windows and cannot be used as file or folder names in SharePoint. A file named CON.docx or a folder named AUX will be rejected. |
| Ampersand in names | The ampersand (&) is technically permitted but causes problems in HTML contexts, some REST API calls, and certain migration tool implementations. |
Potential issues in third-party tooling and when constructing SharePoint REST API URLs manually. Avoid in file and folder names if possible. |
| Square brackets | Square brackets ([ ]) are permitted in file names but cause errors when used in SharePoint CAML queries, PnP PowerShell filters, and some migration tools. |
Files with square brackets in the name may be unreachable through certain APIs. Rename before migrating if possible. |
What Characters Are Blocked in SharePoint File Names?
SharePoint Online blocks ten characters in file and folder names: the double quote ("), asterisk (*), colon (:), less-than sign (<), greater-than sign (>), question mark (?), forward slash (/), backslash (\), pipe (|), hash (#), and percent sign (%). The first eight mirror the characters Windows itself disallows in file names. The hash and percent signs are blocked because they serve as URL fragment and encoding markers respectively, and their presence in a SharePoint file name produces URLs that browsers and web clients cannot resolve reliably.
These restrictions apply equally to file names and folder names throughout the SharePoint Online document library hierarchy. There is no difference in enforcement between the root of a document library and a deeply nested subfolder.
Migration implications
Files migrated from on-premises file servers, network shares, or older SharePoint on-premises installations frequently contain names with characters that SharePoint Online rejects. Common offenders include colons in date-stamped filenames (Report 14:30.xlsx), hashes used as version markers (Brief #3 Final.docx), and backslashes inherited from legacy naming conventions. A migration that does not pre-scan and rename these files will produce a partial migration with unexplained skipped items.
ShareMaster's Clone Master handles cross-tenant and library-to-library migrations within SharePoint Online. For pre-migration cleanup of blocked-character filenames in a source file system, review the file inventory before beginning the migration job so you can agree renames with content owners before moving data.
Path and URL Length Limits
File name character restrictions are one constraint; URL path length is another, and it is the one most often missed until a migration or sync problem surfaces it.
| Limit type | Hard limit | Recommended ceiling | Notes |
|---|---|---|---|
| File name length | 400 characters | 100 characters | The file name itself (not including folder path). Longer names are technically accepted up to the limit but make manual navigation and URL construction difficult. |
| Folder name length | 400 characters | 50 characters | Same limit as file names. Each folder in a deeply nested hierarchy contributes its length to the total URL path. |
| Server-relative URL path | 400 characters | 260 characters | The path component after the host name, for example /sites/marketing/documents/subfolder/file.docx. The 400-character hard limit is enforced by SharePoint Online. The 260-character recommendation preserves compatibility with the Windows default MAX_PATH limit. |
| Full URL (including host name) | No separate SharePoint hard limit | 400 characters total | Keeping the full URL under 400 characters avoids compatibility issues with older browsers, email clients, and some third-party tools. |
| Folder nesting depth | No hard limit | 10 levels | SharePoint Online has no enforced limit on folder depth, but performance degrades beyond around 10-15 levels. Each additional level also adds to the URL path, making the 400-character URL limit easier to hit accidentally. |
The Windows sync client and MAX_PATH
The OneDrive for Business sync client enforces the Windows MAX_PATH constraint: 260 characters, on machines that have not opted into long-path support. A file at C:\Users\username\OneDrive - Contoso\sites\marketing\documents\archive\2023\Q3\project\draft\version2\budget.xlsx will fail to sync if the full local path exceeds 260 characters. Users syncing deeply nested or long-named folders encounter errors that appear to come from OneDrive with no clear explanation of the cause.
Windows 10 version 1607 and later supports paths longer than 260 characters when the LongPathsEnabled group policy setting is enabled, or when the registry key HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled is set to 1. Enabling this setting resolves sync failures for most long-path cases, but it requires a coordinated rollout across managed devices.
For a full view of SharePoint Online limits including list item thresholds and site collection quotas, see the SharePoint Online Limits and Quotas Reference.
Renaming Files Before Migration: A Practical Checklist
When preparing a file inventory for migration into SharePoint Online, apply the following checks before the migration job begins:
- Scan all source file names for the ten blocked characters (
" * : < > ? / \ | # %) and compile a rename list for each match. - Check for leading or trailing spaces in file and folder names. These often appear in files created by automated systems or exported from databases.
- Check for trailing periods in file names, particularly in content from macOS or Linux file systems.
- Calculate the full target URL for each file (host + site path + library path + folder path + file name) and flag any that would exceed 260 characters after migration. Deep folder hierarchies on file servers are the most common source of this problem.
- Check folder names for Windows reserved words, particularly in content migrated from non-Windows systems where
CON,AUX, or similar names may have been used as valid folder names. - Check for files with square brackets in their names if the migration destination includes libraries that use CAML queries or PnP PowerShell in their automation.
Addressing naming issues before a migration prevents a class of failures that are time-consuming to diagnose after the fact. For guidance on moving content between SharePoint sites and tenants, see the cross-tenant SharePoint migration guide.