Skip to main content
Bun natively supports .json imports.
package.json
{
  "name": "bun",
  "version": "1.0.0",
  "author": {
    "name": "John Dough",
    "email": "john@dough.com"
  }
}

Import the file like any other source file.
https://mintcdn.com/bun-1dd33a4e-claude-spawn-pty-support/QoBJ_wda4qs1OZ4-/icons/typescript.svg?fit=max&auto=format&n=QoBJ_wda4qs1OZ4-&q=85&s=7e69f1d0981fed9617c1ae7f85ad9758data.ts
import data from "./package.json";

data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"

Bun also supports Import Attributes and JSON modules syntax.
https://mintcdn.com/bun-1dd33a4e-claude-spawn-pty-support/QoBJ_wda4qs1OZ4-/icons/typescript.svg?fit=max&auto=format&n=QoBJ_wda4qs1OZ4-&q=85&s=7e69f1d0981fed9617c1ae7f85ad9758data.ts
import data from "./package.json" with { type: "json" };

data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"

See Docs > Runtime > TypeScript for more information on using TypeScript with Bun.