rembrembdocs

Skip to main content

Bun home pagelight logodark logo

[Runtime

](../../../index.md)[Package Manager

](../../../pm/cli/install/index.md)[Bundler

](../../../bundler/index.md)[Test Runner

](../../../test/index.md)[Guides

](../../index.md)[Reference

](https://bun.com/reference)[Blog

](https://bun.com/blog)[Feedback

](../../../feedback/index.md)

The Bun.file() function accepts a path and returns a BunFile instance. The BunFile class extends Blob, so use the .type property to read the MIME type.

const file = Bun.file("./package.json");
file.type; // application/json

const file = Bun.file("./index.html");
file.type; // text/html

const file = Bun.file("./image.png");
file.type; // image/png

Refer to API > File I/O for more information on working with BunFile.

Was this page helpful?

Suggest editsRaise issue

[

Read a JSON file

Previous

](../json/index.md)[

Check if a file exists

Next

](../exists/index.md)