Skip to main content

Built and signed on GitHub Actions

Utilities for encoding and decoding common formats like hex, base64, and varint

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a week ago (1.0.7)

Port of the Go encoding/hex library.

import {
  decodeHex,
  encodeHex,
} from "@std/encoding/hex";
import { assertEquals } from "@std/assert";

assertEquals(encodeHex("abc"), "616263");

assertEquals(
  decodeHex("616263"),
  new TextEncoder().encode("abc"),
);

Functions

f
decodeHex

Decodes the given hex-encoded string. If the input is malformed, an error is thrown.

f
encodeHex

Converts data into a hex-encoded string.

Type Aliases

Add Package

deno add jsr:@std/encoding

Import symbol

import * as mod from "@std/encoding/hex";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@std/encoding/hex";

Add Package

npx jsr add @std/encoding

Import symbol

import * as mod from "@std/encoding/hex";

Add Package

yarn dlx jsr add @std/encoding

Import symbol

import * as mod from "@std/encoding/hex";

Add Package

pnpm dlx jsr add @std/encoding

Import symbol

import * as mod from "@std/encoding/hex";

Add Package

bunx jsr add @std/encoding

Import symbol

import * as mod from "@std/encoding/hex";