base64-js
Pure JavaScript base64 encoding and decoding for byte arrays, with no native dependencies.
Repository Health
Technical Analysis
base64-js is a small, dependency-free JavaScript library that converts between base64 strings and byte arrays (Uint8Array). It underpins Node.js’s Buffer polyfill behavior in the browser and is one of the most widely used low-level encoding utilities in the npm ecosystem, pulled in transitively by bundlers, blockchain libraries, and countless other packages that need binary-safe base64 handling outside of Node.
The library exposes exactly three functions — byteLength, toByteArray, and fromByteArray — covering the full round-trip between base64 text and raw bytes, including URL-safe base64 variants and correct handling of padding characters.
What You Get
- byteLength(b64) - Computes the exact decoded byte length of a base64 string without allocating memory
- toByteArray(b64) - Decodes a base64 string into a Uint8Array (or plain Array in older environments)
- fromByteArray(uint8) - Encodes a Uint8Array into a base64 string, chunked for large inputs
- URL-safe decoding - Accepts
-and_characters as used in URL-safe base64 variants
Common Use Cases
- Browser Buffer polyfills - Powers base64 encode/decode inside browserify’s and other bundlers’ Buffer shims
- Binary data transport - Encoding binary payloads such as images, files, or crypto keys for JSON or URL-safe transmission
- Blockchain and crypto libraries - Widely used as a transitive dependency for encoding binary keys and signatures
- Legacy browser support - Provides base64 handling in browsers lacking native byte-array-aware atob/btoa behavior
Under The Hood
Architecture The entire module lives in a single file, index.js, with a flat structure: three exported functions (byteLength, toByteArray, fromByteArray) plus a handful of internal helpers (getLens, _byteLength, tripletToBase64, encodeChunk) and two lookup tables built once at module load. There are no classes and no shared mutable state between calls — each call is a pure function-in/value-out transform — so the encode/decode implementation could be swapped out without touching any calling code beyond the same three exports.
Tech Stack
The shipped entry point is plain CommonJS JavaScript (exports.foo = ...) requiring no build step to consume; a hand-written index.d.ts supplies TypeScript typings alongside it. Development tooling includes browserify to produce a browser-ready bundle, babel-minify to minify that bundle, the standard linter for style enforcement, tape for unit tests, and benchmark for performance comparisons.
Code Quality
Tests under test/ (convert.js, corrupt.js, url-safe.js, big-data.js) run via tape and cover round-trip conversion, malformed-input length validation, URL-safe alphabet decoding, and large-buffer handling — a reasonable suite for a small module. Error handling is explicit where it matters (invalid base64 length throws rather than silently failing), and naming and style are kept consistent via the standard linter. CI is configured through a legacy Travis config, and the project shows limited recent maintenance activity.
API Design The public surface is about as minimal as it gets — three top-level functions with no options objects or classes to instantiate — so there is almost no boilerplate to get started. Naming (byteLength/toByteArray/fromByteArray) mirrors Node’s Buffer conventions, letting developers already familiar with Buffer transfer that knowledge immediately. Documentation is limited to a short README methods list and a few explanatory code comments, but the shipped type declarations serve as an informal secondary reference.
Used by 9 apps in this directory
authentik
Authentication · Security
The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.
Authgear
Authentication
Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.
Convex Backend
Developer Tools · Databases
Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.
Huly Platform
Project Management · Team Chat · Collaboration
Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.
Jitsi Meet
Team Chat · Collaboration · Video Conferencing
Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.
Kibana
Analytics · Monitoring
Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
paseo
AI Agents · AI Code Assistants
One unified interface to orchestrate Claude Code, Codex, Copilot, OpenCode, and Pi agents in parallel from desktop, mobile, or the terminal.
swagger-ui
Developer Tools
Transform OpenAPI specifications into interactive, browser-based API documentation that developers and consumers can explore and test live.