Skip to main content
Home

@std/encoding@1.0.10
Built and signed on GitHub Actions

Works with
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 Score100%
Downloads125,690/wk
Published9 months ago (1.0.10)

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

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

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

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

pnpm i jsr:@std/encoding
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/encoding

Import symbol

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

Add Package

yarn add jsr:@std/encoding
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/encoding

Import symbol

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

Add Package

vlt install jsr:@std/encoding

Import symbol

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

Add Package

npx 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";