Convert strings to safe, cross-platform filenames by removing reserved characters and normalizing Unicode.
Filenamify is a JavaScript library that converts any string into a safe, valid filename for use across operating systems. It solves the problem of generating reliable filenames from user input or dynamic content by removing reserved characters and handling Unicode complexities. The library ensures filenames work on both Unix-like systems and Windows without causing errors.
Developers building applications that generate or manipulate filenames from user input, such as file uploaders, content management systems, or CLI tools. It's particularly useful for Node.js backends and browser-based projects needing consistent file naming.
Developers choose Filenamify for its robust handling of edge cases, cross-platform compatibility, and simple API. It stands out by offering Unicode-aware truncation, browser support, and integration with related tools like filenamify-url and slugify.
Convert a string to a valid safe filename
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles reserved characters for both Unix (/) and Windows (<>:\"\|?*), replacing them with a configurable character to ensure filenames work everywhere, as shown in the README examples.
Intelligently limits filename length while preserving extensions and avoiding grapheme splitting, preventing broken Unicode characters in truncated names.
Strips non-printable control characters and Unicode bidirectional marks, ensuring clean and safe filenames without hidden issues.
Offers a browser-only import that excludes Node.js path dependencies, making it easy to use in client-side applications without polyfills.
The replacement character cannot include reserved characters, limiting customization for specific aesthetic or functional needs, as mentioned in the options section.
Defaults to a 100-character filename limit, which may be too restrictive for systems allowing up to 255 characters, requiring manual adjustment for longer filenames.
The filenamifyPath function relies on the Node.js path module, which isn't available in browsers, necessitating separate imports or workarounds for cross-environment use.