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. Use the .delete() method to delete the file.

const path = "/path/to/file.txt";
const file = Bun.file(path);

await file.delete();

See Docs > API > File I/O for complete documentation of Bun.file().

Was this page helpful?

Suggest editsRaise issue

[

Copy a file to another location

Previous

](../file-cp/index.md)[

Delete files

Next

](../../runtime/delete-file/index.md)