[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. Use the .exists() method to check if a file exists at the given path.
index.ts
const path = "/path/to/package.json";
const file = Bun.file(path);
await file.exists(); // boolean;
Refer to API > File I/O for more information on working with BunFile.
Was this page helpful?
[
Get the MIME type of a file
Previous
](../mime/index.md)[
Watch a directory for changes
Next
](../watch/index.md)