The maximum APFS file name length is 255 characters. This limit applies to an individual name component—the name of a file or folder—not to the complete path made up of many nested folders.
APFS stores file names using UTF-8 and supports Unicode characters. That makes the practical experience more complicated than simply counting visible symbols: some characters can require multiple UTF-8 bytes, and applications may impose additional restrictions or display names differently. The slash character is reserved because it separates directories in Unix-style paths.
The 255-character limit is not unique to APFS. HFS+ also supported file names up to 255 Unicode characters, and many Unix file systems use a similar per-component limit. A related misconception is confusing file-name length with path length. A deeply nested APFS path can contain multiple components, each subject to its own limit, while the overall path has separate operating-system and API constraints.