GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Guides
  • Reference
  • Blog
  • Install
  • Home
  • Package Manager
  • Bundler
  • Compiler
  • Test Runner
  • Linter
  • Formatter
  • Feedback
  • Deploy on Vercel

This view

  • Original page
  • New address

GeezerVison is showing bun.com — Read a JSON file | Bun Guides

Guides

The Bun.file() function accepts a path and returns a BunFile instance. BunFile extends Blob, so you can read the file lazily in a variety of formats. Use .json() to read and parse the contents of a .json file as a plain object.

Bun sets the MIME type of the BunFile accordingly.

index.ts
const path = "/path/to/package.json";
const file = Bun.file(path);

const contents = await file.json();
// { name: "my-package" }

file.type; // => "application/json;charset=utf-8";
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.