npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

blob-to-url

v0.3.6

Published

Zero-dependency utility for generating blob URLs and base64 data URIs. ESM, CJS, and IIFE with TypeScript types.

Readme

blob-to-url

npm version npm downloads/week npm downloads/month npm total downloads size min license types TypeScript dependencies CI issues last commit

A lightweight, zero-dependency utility for generating blob URLs and base64 data URIs in the browser. Ships ESM, CommonJS, and IIFE builds with TypeScript definitions.

Installation

npm install blob-to-url
# or
pnpm add blob-to-url
# or
yarn add blob-to-url

Quick Start

ESM / TypeScript

import { toBlobURL, toDataURI } from "blob-to-url";

// Create a blob URL
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
const { url, revoke } = toBlobURL(blob);

console.log(url);      // blob:http://...
revoke();              // Release browser resources

// Convert blob to data URI (async)
const dataURI = await toDataURI(blob);
console.log(dataURI);  // data:text/plain;base64,SGVsbG8sIHdvcmxkIQ==

CommonJS

const { toBlobURL, toDataURI } = require("blob-to-url");

Browser (IIFE via CDN)

<script src="https://unpkg.com/blob-to-url"></script>
<script>
  const { toBlobURL, toDataURI } = blobToUrl;

  const blob = new Blob(["Hello!"], { type: "text/plain" });
  const { url } = toBlobURL(blob);
  console.log(url); // blob:...
</script>

API

toBlobURL(blob: File | Blob): { url: string; revoke: () => void }

Creates a browser-cached URL for a File or Blob using URL.createObjectURL. Returns an object with:

  • url — the generated blob URL string
  • revoke — cleanup function that calls URL.revokeObjectURL
const image = new Blob([imageData], { type: "image/png" });
const { url, revoke } = toBlobURL(image);

document.getElementById("preview").src = url;
revoke(); // Call when the URL is no longer needed

toDataURI(blob: File | Blob): Promise<string>

Converts a File or Blob to a base64-encoded data URI using FileReader.readAsDataURL. Returns a Promise that resolves with the data URI string.

const blob = new Blob(['{"key":"value"}'], { type: "application/json" });
const uri = await toDataURI(blob);
// uri = "data:application/json;base64,eyJrZXkiOiJ2YWx1ZSJ9"

Features

  • Zero dependencies — no runtime dependencies, tiny bundle
  • ESM, CommonJS, and IIFE — works everywhere
  • TypeScript-first — type definitions included out of the box
  • Tree-shakeable — import only what you need
  • Lightweight — < 1KB minified + gzipped

Build

This package uses tsdown — powered by Rolldown and Oxc — for ESM, CJS, IIFE, and type declaration generation in a single build step.

Development

pnpm install          # Install dependencies
pnpm build            # Build all outputs
pnpm test             # Run tests (requires build first)
pnpm test:ci          # Run tests (CI mode)

Releases

This project uses release-please for automated version management. Release PRs are automatically created when conventional commits (feat:, fix:, !: for breaking changes) are pushed to main.

To trigger a code review or fix, comment /oc on any issue or pull request.

License

MIT © devcomfort