Plate IThe ES2026 Uint8Array base64 and hex methods, in every runtime

Bytes to base64 and hex, the way the spec says.

hexowl gives you toBase64, fromBase64, toHex, fromHex, setFromBase64 and setFromHex with the exact behavior of the ECMAScript standard: same results, same errors, same whitespace rules. It uses the native methods when your runtime has them and a fast, dependency free implementation when it does not.

npm i hexowl
aGV4b3ds

Type in the eyepiece. Each character of the base64 output lights up on the alphabet ring, joined in order.

4.0KiBgzipped
0dependencies
100%line coverage
6standard methods

Same results in every runtime

Node.jsBunDenoChromeFirefoxSafari
IThe problem

Why it exists

RA 04h 21m
Dec +16° 30′
SGVsb!

Every project ends up with a base64 helper. Most of them quietly accept garbage: they skip unknown characters, mix both alphabets, or turn bad input into zero bytes. ES2026 finally standardised strict, well defined methods on Uint8Array, but older Node.js versions and browsers do not have them yet. hexowl lets you write against the standard API today, get the standard errors today, and drop the library tomorrow without changing a single result.

  • Rejects exactly what the standard rejects
  • Same errors and the same partial writes
  • Remove it later and nothing changes
IIWhy hexowl

Features

RA 06h 45m
Dec -16° 43′

Hover or focus an entry to find its star on the chart.

HXO1

Spec exact

Follows the ECMAScript algorithms step by step: option read order, whitespace, padding, extra bits, partial writes before an error, TypeError versus SyntaxError.

fromBase64('QQ', { lastChunkHandling })
'loose'[65]
'strict'SyntaxError
'stop-before-partial'[]
HXO2

Native first

When the runtime ships all six methods, hexowl simply calls them. You get engine speed and identical results.

yes native codeno hexowl code
HXO3

Fast fallback

A tuned pure JavaScript path everywhere else. In Node.js, large inputs go through Buffer, but only when the answer is provably the same.

hexowl5400
base64-js119
js-base64304
base64 encode, 1 KiB, Node.js 24, MB/s
HXO4

Tiny, zero dependencies

About 4 KiB gzipped, tree shakeable named exports, no Buffer requirement, no globals touched.

HXO5

Ponyfill or polyfill

Import functions, or call install() once to add only the methods your runtime is missing.

import { toHex } from 'hexowl'
install(); // Uint8Array.prototype.toHex
HXO6

Typed, ESM and CommonJS

Hand written TypeScript declarations, an exports map for import and require, Node.js 18 and later, Bun, Deno and browsers.

index.js ESMindex.cjs CommonJSindex.d.ts TypeScript
IIITry it

Playground

RA 18h 36m
Dec +38° 47′

This runs the real hexowl code that ships on npm, inlined into this page. When your browser has the native methods, their answer is shown next to it.

Obs. loglive
Operation
Alphabet
Omit padding
lastChunkHandling
Target size:
Try
   whitespace= padding! invalid
hexowl
Native Same result as the native method Differs from this browser's native method
Byte constellation

Each byte is a star on a 16 by 16 hex lattice: the row is the high nibble, the column the low nibble. Stars are joined in order.

IVDeveloper experience

Use it

RA 14h 15m
Dec +19° 10′
  1. import { toBase64, fromBase64, toHex, fromHex } from 'hexowl';
  2. const bytes = new TextEncoder().encode('Hello, owl!');
  3. toBase64(bytes); // 'SGVsbG8sIG93bCE='
  4. toBase64(bytes, { alphabet: 'base64url', omitPadding: true }); // 'SGVsbG8sIG93bCE'
  5. toHex(bytes); // '48656c6c6f2c206f776c21'
  6. fromBase64('SGVsbG8sIG93bCE='); // Uint8Array(11) [72, 101, ...]
  7. fromHex('cafe'); // Uint8Array(2) [202, 254]
  8. fromBase64('SGl=', { lastChunkHandling: 'strict' }); // throws SyntaxError

API at a glance

Six functions mirror the six methods. Every option and error matches the standard. The full reference is in the README.

APIReturnsThrows
toBase64(bytes, { alphabet, omitPadding }?)stringTypeError
fromBase64(string, { alphabet, lastChunkHandling }?)Uint8ArrayTypeError, SyntaxError
setFromBase64(target, string, options?){ read, written }TypeError, SyntaxError
toHex(bytes)stringTypeError
fromHex(string)Uint8ArrayTypeError, SyntaxError
setFromHex(target, string){ read, written }TypeError, SyntaxError
install()string[]
nativeSupportboolean
VPerformance

Benchmarks

RA 05h 55m
Dec +07° 24′

Median throughput in MB/s of raw bytes, higher is better. Measured on AMD Ryzen 7 7800X3D, Windows 10 (2026-12-04). In Node.js 24 there are no native methods, so hexowl uses its own code and Buffer. In Bun, hexowl calls the native methods.

Runtime
Operation
Input size
hexowlhexowl: 5400 MB/s5400hexowl (pure JS)hexowl (pure JS): 263 MB/s263BufferBuffer: 6065 MB/s6065base64-js 1.5.1base64-js 1.5.1: 119 MB/s119js-base64 3.9.8js-base64 3.9.8: 304 MB/s304

Honest notes: plain Buffer is still faster than hexowl in Node.js, because hexowl validates input that Buffer accepts silently. For tiny inputs of 32 bytes, the fixed call overhead dominates for everyone.

VIComparison

How it compares

RA 10h 08m
Dec +11° 58′

Checked by running each option on Node.js 24, not copied from their docs. Versions: base64-js 1.5.1 and js-base64 3.9.8.

CapabilityhexowlBufferatob / btoabase64-jsjs-base64
Works on Uint8ArrayYesYesNoYesYes
base64url alphabetYesYesNoPartlyYes
Rejects invalid charactersYesNoYesNoPartly
HexYesYesNoNoNo
Decodes into an existing bufferYesYesNoNoNo
The standard API, removable laterYesNoNoNoNo
Runs in browsers without BufferYesPartlyYesYesYes
Legend:YesPartlyNo

Partly means: base64-js decodes base64url but only encodes the standard alphabet; js-base64 skips invalid characters when decoding and offers a separate isValid check; Buffer is a Node.js API that some other runtimes emulate.

Compatibility

RuntimeWhat hexowl uses
Node.js 18, 20, 22, 24pure JavaScript, Buffer for large inputs
Bun 1.3native methods
Deno 2.xnative methods
Browsers with the methods (Chrome 140, Firefox 133, Safari 18.2)native methods
Browsers without the methodspure JavaScript

Size

The ESM entry, comments and indentation stripped, gzipped at level 9. A real minifier makes it smaller still.

4.0 KiBgzipped
15.8 KiBstripped
0runtime dependencies
VIIQuestions

FAQ

RA 22h 57m
Dec -29° 37′

Still curious? The README covers every option and every error. Documentation

Buffer only exists in Node.js and accepts invalid input without complaint. atob works on binary strings, not bytes, has no base64url and no streaming. The standard methods fix all of that, and hexowl makes them available everywhere.

Plate VIIInpm i hexowl

Write against the standard today.

Install hexowl, use the ES2026 methods everywhere, and remove it once every runtime you support has them. None of your results will change.

npm i hexowl