js-base64

Pure-JavaScript Base64 encoder/decoder with full Unicode and URL-safe support

Library
npm
v3.9.3
4,361stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity88
Maintenance44
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture75
Code Quality80
Innovation65
Learning Curve85

js-base64 is a dependency-free Base64 transcoder for JavaScript and TypeScript that works consistently across browsers, Node.js, Deno, and Bun. Unlike the built-in btoa/atob functions, which only handle Latin1 binary strings and throw on non-ASCII text, js-base64 correctly encodes and decodes arbitrary Unicode strings (including emoji and multi-byte UTF-8 text) by internally using TextEncoder/TextDecoder where available and falling back to hand-written polyfills where they are not.

The library ships as CommonJS, an ES module, and a UMD/browser global, with first-class TypeScript declaration files for both, so it drops into virtually any JavaScript environment without configuration. It also supports the URL-safe Base64 variant (-/_ instead of +//, no padding) out of the box, which is commonly needed for JWTs, URL query parameters, and filenames — one of the most common reasons projects reach for a dedicated Base64 library instead of the platform built-ins.

What You Get

  • Base64.encode/Base64.decode functions that correctly round-trip full Unicode strings, including multi-byte UTF-8 and emoji
  • URL-safe Base64 encoding/decoding (-/_ alphabet, optional padding removal) for use in JWTs, URLs, and filenames
  • Drop-in polyfills for native btoa/atob behavior where the environment lacks them
  • Distribution as CommonJS (base64.js), ES module (base64.mjs), and UMD/browser global, each with matching TypeScript declarations
  • Zero runtime dependencies and a small, auditable single-file implementation

Common Use Cases

  • Encoding/decoding JWT header and payload segments in auth middleware
  • Safely embedding binary data (images, files) as Base64 strings in JSON payloads or data URIs
  • URL-safe encoding of identifiers or tokens passed as query parameters or path segments
  • Cross-runtime utilities that need identical Base64 behavior in both browser and Node.js/Deno code
  • Encoding Unicode strings for storage or transport where native btoa would throw on non-Latin1 characters

Under The Hood

Architecture The library is authored as a single TypeScript source file (base64.ts, ~300 lines) that is compiled to three distribution targets: a CommonJS build (base64.js), an ES module (base64.mjs), and matching .d.ts/.d.mts type declarations, all wired together via package.json exports conditions so bundlers and runtimes resolve the right format automatically. Internally, encode/decode operations branch on feature detection: where TextEncoder/TextDecoder are available (all modern browsers, Node, Deno, Bun) they’re used directly for UTF-8 conversion; where they aren’t, hand-written btoaPolyfill/atobPolyfill functions perform the same conversion byte-by-byte using character-code arithmetic.

Tech Stack Written in TypeScript with zero runtime dependencies, built via a Makefile (not a JS bundler) that invokes tsc to emit the CJS/ESM/type-declaration outputs, and tested with Mocha. The test/ directory includes targeted suites for BOM handling, large-input performance, atob compatibility, and ES5 vs ES6 code paths.

Code Quality Test coverage spans edge cases specific to Base64/Unicode correctness — byte-order-mark handling (bom.js), large payloads (large.js), ES5 fallback behavior (es5.js) — rather than just happy-path encode/decode, reflecting the project’s long history of fixing subtle cross-environment bugs. The single-file implementation keeps the surface area small enough to audit fully, and inline JSDoc comments document each exported function’s parameters and return values.

API Design The API centers on a Base64 namespace object (Base64.encode, Base64.decode, Base64.encodeURI, etc.) plus equivalent named exports (encode, decode) for consumers who prefer tree-shakeable imports over the namespace object — both documented side by side in the README so migrating between styles is a one-line change. noConflict() is provided for browser-global usage to avoid clobbering an existing Base64 global, a detail that shows attention to real-world script-tag consumption alongside modern module usage.

Used by 20 apps in this directory

Go
72%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,573

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go72%
Vue28%
Updated today
TypeScript
96%
Other

CapRover

Developer Tools · Devops · Hosting Control Panel

15,132

Deploy any app, database, or website to your own server in minutes—no Docker or Linux expertise required.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript96%
Updated 3 days ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
99%
Apache 2.0

Colanode

Knowledge Management · Team Chat · Collaboration

5,018

Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.

View details
47
Repo Health
73
Technical
73
Dependency
Built with
TypeScript99%
Updated 4 months ago
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,394

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.

View details
88
Repo Health
82
Technical
70
Dependency
Built with
TypeScript45%
Rust43%
Updated today
Java
78%
GPL 3.0

DataEase

Analytics · Data Engineering · AI Assistants

24,346

Open-source BI tool with drag-and-drop dashboards, 20+ data source connectors, and AI-powered natural language queries — a self-hosted alternative to Tableau.

View details
94
Repo Health
71
Technical
66
Dependency
Built with
Java78%
Vue22%
Updated today
PHP
66%
AGPL 3.0

EspoCRM

Marketing · Ecommerce · CRM

3,259

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
64
Dependency
Built with
PHP66%
JavaScript24%
Updated yesterday
Vue
50%
GPL 3.0

IT-Tools

Developer Tools

40,279

A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.

View details
60
Repo Health
74
Technical
67
Dependency
Built with
Vue50%
TypeScript48%
Updated 3 days ago
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,083

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
68
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search