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-utils

v1.0.3

Published

TypeScript browser utilities for Blob, File, Base64 conversion, object URLs, and file downloads.

Readme

blob-utils

npm version npm downloads license

Lightweight TypeScript utilities for Blob, File, Base64, object URLs, and browser downloads.

Version: 1.0.2

License: MIT

Developer: Sanish Vasudevan

Installation

npm install blob-utils

Exported Utilities

  • base64ToBlob(base64, mimeType?)
  • isBase64(str)
  • getMimeType(base64)
  • blobToFile(blob, filename)
  • base64ToFile(base64, filename)
  • toObjectURL(blob)
  • revokeObjectURL(url)
  • createObjectURL(blob)
  • releaseObjectURL(url)
  • downloadBlob(blob, filename)
  • downloadBase64(base64, filename)
  • downloadFromUrl(url, filename?)

Quick Usage

import {
  base64ToBlob,
  base64ToFile,
  blobToFile,
  toObjectURL,
  revokeObjectURL,
  createObjectURL,
  releaseObjectURL,
  downloadBlob,
  downloadBase64,
  downloadFromUrl,
  getMimeType,
  isBase64,
} from 'blob-utils'

const dataUrl = 'data:text/plain;base64,SGVsbG8sIHdvcmxkIQ=='

const blob = base64ToBlob(dataUrl)
const file = base64ToFile(dataUrl, 'hello.txt')
const sameAsFile = blobToFile(blob, 'copy.txt')

console.log(isBase64(dataUrl)) // true
console.log(getMimeType(dataUrl)) // text/plain

const objectURL = createObjectURL(blob)
releaseObjectURL(objectURL)

const legacyURL = toObjectURL(blob)
revokeObjectURL(legacyURL)

downloadBlob(blob, 'hello.txt')
downloadBase64(dataUrl, 'hello-base64.txt')
await downloadFromUrl('https://example.com/report.pdf', 'report.pdf')

API Tutorials

base64ToBlob(base64, mimeType?)

Converts raw base64 or a data URL into a Blob.

import { base64ToBlob } from 'blob-utils'

const dataUrl = 'data:text/plain;base64,SGVsbG8='
const blob = base64ToBlob(dataUrl)
const pngBlob = base64ToBlob('iVBORw0KGgoAAAANSUhEUgAA...', 'image/png')

isBase64(str)

Checks whether a string is valid raw base64 or valid data URL payload.

import { isBase64 } from 'blob-utils'

isBase64('SGVsbG8=') // true
isBase64('data:text/plain;base64,SGVsbG8=') // true
isBase64('not-base64') // false

getMimeType(base64)

Extracts MIME type from a data URL. Returns null for plain base64.

import { getMimeType } from 'blob-utils'

getMimeType('data:image/png;base64,iVBORw0KGgo...') // image/png
getMimeType('SGVsbG8=') // null

blobToFile(blob, filename)

Converts a Blob to a browser File.

import { blobToFile } from 'blob-utils'

const blob = new Blob(['hello'], { type: 'text/plain' })
const file = blobToFile(blob, 'hello.txt')

base64ToFile(base64, filename)

Converts raw base64 or data URL directly to File.

import { base64ToFile } from 'blob-utils'

const file = base64ToFile('data:text/plain;base64,SGVsbG8=', 'hello.txt')

createObjectURL(blob) and releaseObjectURL(url)

Preferred object URL helpers.

import { createObjectURL, releaseObjectURL } from 'blob-utils'

const blob = new Blob(['preview'])
const url = createObjectURL(blob)

// use URL in img/video/a tags...

releaseObjectURL(url)

toObjectURL(blob) and revokeObjectURL(url)

Equivalent helpers with alternate naming.

import { toObjectURL, revokeObjectURL } from 'blob-utils'

const blob = new Blob(['preview'])
const url = toObjectURL(blob)
revokeObjectURL(url)

downloadBlob(blob, filename)

Triggers browser download for a Blob.

import { downloadBlob } from 'blob-utils'

const blob = new Blob(['hello'], { type: 'text/plain' })
downloadBlob(blob, 'hello.txt')

downloadBase64(base64, filename)

Triggers browser download from raw base64 or data URL.

import { downloadBase64 } from 'blob-utils'

downloadBase64('data:text/plain;base64,SGVsbG8=', 'hello.txt')

downloadFromUrl(url, filename?)

Fetches a file URL and downloads it in the browser.

import { downloadFromUrl } from 'blob-utils'

await downloadFromUrl('https://example.com/manual.pdf', 'manual.pdf')

// If filename is omitted, the name is inferred from URL path.
await downloadFromUrl('https://example.com/files/report.csv')

Notes

  • This package is browser-focused (Blob, File, URL, document, fetch APIs).
  • For downloadFromUrl, cross-origin servers must allow fetch access (CORS).