> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# Read a JSON file

> Parse JSON files with Bun

Bun can parse JSON files directly.

## Read JSON File

```typescript theme={null}
const file = Bun.file("data.json");
const data = await file.json();
console.log(data);
```

## With Type Safety

```typescript theme={null}
interface User {
  name: string;
  email: string;
}

const file = Bun.file("users.json");
const users: User[] = await file.json();
```

## Error Handling

```typescript theme={null}
try {
  const file = Bun.file("config.json");
  const config = await file.json();
} catch (error) {
  console.error("Invalid JSON:", error);
}
```

See [File I/O](/api/file-io) for complete documentation.
