# Bun Check if a file exists

> Check if a file exists

- Skill: `jarle/bun-check-if-a-file-exists` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jarle/bun-check-if-a-file-exists`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jarle/bun-check-if-a-file-exists/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jarle (https://skillmd.com/u/jarle)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/jarle/bun-check-if-a-file-exists

---


# Check if a file exists

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.

```ts index.ts icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
const path = "/path/to/package.json";
const file = Bun.file(path);

await file.exists(); // boolean;
```

***

Refer to [API > File I/O](/runtime/file-io) for more information on working with `BunFile`.

