Overview
Koyo is a zero-dependency standard library for TypeScript and JavaScript — string, number, array, object, and math utilities, plus reactive state, a typed DOM layer, and one error hierarchy across all of it. Everything behaves identically on Node.js, Bun, browsers, and edge runtimes.
Installation
npm install koyojsbun add koyojsImport styles
Koyo supports two import patterns:
// 1. Named exports from the root (simple)
import { slugify, clamp, chunk, pick } from "koyojs";
// 2. Per-module imports (better tree-shaking)
import { toCamelCase } from "koyojs/String";
import { randomInt } from "koyojs/Number";
import { chunk } from "koyojs/Array";
import { pick } from "koyojs/Object";
import { gcd } from "koyojs/Math";
import { signal } from "koyojs/State";
import { $ } from "koyojs/DOM";
import { KoyoError } from "koyojs/Error";Modules
String
capitalize · camelCase · snake_case · slugify · truncate · isEmail · isURL · isPhoneNumber
View APINumber
clamp · randomInt · sum · average · isEven · isOdd
View APIArray
chunk · flatten · unique · removeDuplicates · groupBy · createArray
View APIObject
pick · omit · extract · exclude · cloneDeep · cloneShallow
View APIMath
gcd · lcm · factorial · isPrime · isqrt · floorDiv · mod · comb · perm · isClose · kahanSum · roundTo · lerp · dist
View APIState
signal · memo · effect · batch · untrack · onCleanup · createRoot · component · useState · useEffect · useMemo · useRef · useReducer
View APIDOM
$ · find · closest · addClass · attr · data · val · text · html · append · css · show · hide · on · off · trigger · ready · parseHTML
View APIError
KoyoError · KoyoTypeError · KoyoRangeError · KoyoStateError · KoyoDOMError · createError · isKoyoError · assert
View APIPhilosophy
JavaScript has no proper standard library. The same operation behaves differently across environments, and every project ends up pulling in dozens of micro-packages to fill the gaps — one for string casing, one for deep cloning, one for reactivity, one for DOM helpers, each with its own conventions and its own error types.
Koyo covers that ground as a single, coherent piece: zero external dependencies, one module per concern, and consistent behaviour across every runtime. The utility modules stay one file per function so bundlers can drop what you don't import; State and DOM are larger by necessity, but remain separate entry points you only pay for when you reach for them.