> ## 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.

# Write a string to a file

> Write files with Bun

Bun provides fast file writing with `Bun.write()`.

## Write String to File

```typescript theme={null}
await Bun.write("output.txt", "Hello World");
```

## Write JSON

```typescript theme={null}
const data = { name: "John", age: 30 };
await Bun.write("data.json", JSON.stringify(data, null, 2));
```

## Append to File

```typescript theme={null}
const file = Bun.file("log.txt");
await Bun.write(file, "New log entry\n", { append: true });
```

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