Building Thirty Developer Tools with Zero Dependencies
Building a collection of small developer utilities - formatters, converters, generators, decoders - invites a package per tool. Each one exists, each is well tested, and each is one install away. Choosing not to use any of them is a constraint worth examining, because the result was not the sacrifice it sounds like.
The honest summary is that roughly ninety percent of these tools are a short function over a browser primitive that already exists, and the remaining ten percent are things you should not be writing yourself at all. Separating those two groups is most of the value.
Why impose the rule
- Each dependency is a supply chain entry, and a utility site is a lot of surface for very little logic.
- Bundle size is per page, and a page whose whole purpose is one text transformation should not ship a general-purpose library.
- Longevity: a site with no dependencies still builds in three years with no upgrade work.
- Generality costs more than it returns here - most libraries solve a far larger problem than the tool needs.
- Understanding: writing it once means you can actually fix it.
Separate the engine from the interface
The structural decision that made the constraint workable was keeping every piece of logic as a plain function with no knowledge of the framework, the DOM, or how it would be displayed.
// engine: input in, result out, no DOM, no framework, no globals
export function formatJson(text, { indent = 2 } = {}) {
try {
return { ok: true, value: JSON.stringify(JSON.parse(text), null, indent) };
} catch (error) {
return { ok: false, error: describeJsonError(text, error) };
}
}Returning a result object rather than throwing matters more than it looks. These tools spend most of their time being given invalid input on purpose - that is what they are for - so a parse failure is an ordinary outcome that needs a good message, not an exception.
The separation also makes testing trivial. A pure function is tested with a table of inputs and expected outputs, with no rendering, no mounting, and nothing to mock.
What the platform already provides
The most useful outcome of the exercise was an inventory of things that need no library at all.
| Need | Built-in |
|---|---|
| Secure random values | crypto.getRandomValues and crypto.randomUUID |
| Text and byte conversion | TextEncoder and TextDecoder |
| Date formatting and time zones | Intl.DateTimeFormat with a time zone option |
| Relative time in any locale | Intl.RelativeTimeFormat |
| Number, currency and unit formatting | Intl.NumberFormat |
| URL parsing and query strings | URL and URLSearchParams |
| HTML and XML parsing | DOMParser |
| Deep copying structured values | structuredClone |
| Image decoding, resizing and re-encoding | Canvas with createImageBitmap and toBlob |
| Hashing | crypto.subtle.digest |
Time zone handling is the clearest example. The usual instinct is a date library, but converting an instant into a named zone and formatting it for a locale is a single built-in call, and it is backed by the system's own time zone data rather than a bundled copy that ages.
The encoding trap everyone hits
Base64 looks like the easiest tool in the set and contains the one bug nearly every implementation ships with: the built-in encoder operates on bytes in a single-byte range, so any input outside it throws.
// Breaks on any non-Latin1 character
btoa('Grüße'); // InvalidCharacterError
// Encode to UTF-8 bytes first, then base64 those bytes
export function encodeBase64(text) {
const bytes = new TextEncoder().encode(text);
let binary = '';
bytes.forEach((b) => { binary += String.fromCharCode(b); });
return btoa(binary);
}This is the general shape of what the constraint teaches. The primitive exists and is correct; the gap is a thin conversion layer that a library would have hidden, and hidden layers are exactly what you stop understanding.
Where the rule should break
Some things are genuinely not appropriate to write yourself, and pretending otherwise would produce a tool that is worse than useless because it looks authoritative.
- Cryptographic verification. Decoding a token to show its claims is string handling; verifying its signature is cryptography with real consequences for getting it subtly wrong.
- Complete language parsers. Formatting a query by reflowing keywords is honest; claiming to parse a full dialect is not.
- Image codecs beyond what the browser decodes natively.
- Anything where being approximately right is indistinguishable from being wrong.
The resolution in each case was not to install something, but to narrow the claim and say so plainly in the interface. A token decoder that states clearly that it decodes and does not verify is useful and honest. One that implies verification it does not perform is a liability regardless of how it was built.
Say what a tool does not do
That labelling turns out to be a general principle rather than a special case for cryptography. A formatter that does not validate against a schema, a converter that assumes a particular encoding, a generator whose randomness is suitable for identifiers but not for secrets - each should say so where the user is looking. It is the interface equivalent of returning the derivation rather than only the answer: the output alone does not tell the user how far to trust it.
What it actually cost
Honest accounting: a handful of tools took noticeably longer than installing a package would have, and two behave slightly less comprehensively than a mature library would. The offsetting gains were that each page loads only its own small engine, nothing needed upgrading for security advisories, and every behaviour in the collection is one file away from being understood.
For an application with real domain complexity, that trade would usually go the other way. For a set of small, well-understood transformations, the library was solving a problem the project did not have.
Conclusion
The rule was worth keeping not because dependencies are bad but because it forced a question that normally goes unasked: what does this actually require? The answer was usually a browser primitive plus twenty lines. Keep the logic as pure functions so it stays testable and portable, learn what the platform already gives you, and break the rule deliberately for the few things where being approximately correct is the same as being wrong - then say so where the user can see it.