A zero-dependency JavaScript utility library. Works in the browser and Node.js. Tree-shakeable ESM + CJS + CDN script tag.
Or via CDN (no install):
< script src ="https://utilitx.pages.dev/utilitx.min.js "> </ script >
import { slugify , chunk , timeAgo , debounce } from 'utilitx' ;
slugify ( "Hello World!" ) ; // "hello-world"
chunk ( [ 1 , 2 , 3 , 4 , 5 ] , 2 ) ; // [[1,2],[3,4],[5]]
timeAgo ( new Date ( Date . now ( ) - 90000 ) ) ; // "1 minute ago"
< script src ="https://utilitx.pages.dev/utilitx.min.js "> </ script >
< script >
console . log ( utilitx . slugify ( "Hello World" ) ) ; // "hello-world"
</ script >
const { slugify, isEmail } = require ( 'utilitx' ) ;
Function
Description
slugify(str)
URL-safe slug from any string
truncate(str, len)
Truncate with ellipsis
capitalize(str)
Capitalize first letter
camelCase(str)
dash-or-space to camelCase
escapeHtml(str)
Escape < > & " '
Function
Description
chunk(arr, size)
Split into equal-sized chunks
unique(arr)
Remove duplicates
flatten(arr)
Deep flatten nested arrays
shuffle(arr)
Fisher-Yates shuffle (non-mutating)
groupBy(arr, key)
Group objects by a property
Function
Description
deepClone(obj)
Deep clone (JSON-safe)
deepMerge(a, b)
Recursive object merge
pick(obj, keys)
Extract keys into new object
omit(obj, keys)
Remove keys from new object
Function
Description
clamp(n, min, max)
Keep n between bounds
randomInt(min, max)
Random integer, inclusive
formatBytes(bytes)
1048576 → "1 MB"
lerp(a, b, t)
Linear interpolation
Function
Description
timeAgo(date)
"3 hours ago"
formatDate(date, fmt)
"YYYY-MM-DD" etc.
daysBetween(a, b)
Integer day difference
Function
Description
isEmail(str)
Email format check
isURL(str)
URL format check
isEmpty(val)
Null / undefined / "" / [] / {}
isUUID(str)
UUID v4 format check
Function
Description
sleep(ms)
Promise delay
retry(fn, n, delay)
Retry async fn on failure
debounce(fn, ms)
Fire after inactivity
throttle(fn, ms)
Fire at most once per ms
Function
Description
copyToClipboard(str)
Copy to clipboard (Promise)
scrollTo(el)
Smooth scroll to element
onClickOutside(el, fn)
Click-outside listener
Deploying to Cloudflare Pages
Fork this repo on GitHub
Go to pages.cloudflare.com → Create a project
Connect your GitHub account and select this repo
Set Build command to: npm run build
Set Output directory to: dist
Click Save and Deploy — done!
Every git push to main auto-deploys.
PRs welcome! Please add a test in tests/ for any new function.
MIT © 2026