# Read & write files - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/sandbox-filesystem-read-write

# Read & write files

##

[​](#reading-files)

Reading files

You can use the `files.read()` method to read files from the sandbox filesystem.

JavaScript & TypeScript

Python

```
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create()

// Create a file in the sandbox for testing
const filePathInSandbox = '/tmp/test-file'
await sandbox.files.write(filePathInSandbox, "test-file-content")

const fileContent = await sandbox.files.read(filePathInSandbox)
console.log(fileContent)

await sandbox.kill()
```

```
from novita_sandbox.code_interpreter import Sandbox

sandbox = Sandbox.create()

file_path_in_sandbox = '/tmp/test-file'
sandbox.files.write(file_path_in_sandbox, "test-file-content")

file_content = sandbox.files.read(file_path_in_sandbox)
print(file_content)

sandbox.kill()
```

##

[​](#writing-single-files)

Writing single files

You can use the `files.write()` method to write single files to the sandbox filesystem.

JavaScript & TypeScript

Python

```
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create()

const filePathInSandbox = '/tmp/test-file'

const result = await sandbox.files.write(filePathInSandbox, "test-file-content")
console.log(result)

await sandbox.kill()
```

```
from novita_sandbox.code_interpreter import Sandbox

sandbox = Sandbox.create()

file_path_in_sandbox = '/tmp/test-file'
result = sandbox.files.write(file_path_in_sandbox, "test-file-content")
print(result)

sandbox.kill()
```

##

[​](#writing-multiple-files)

Writing multiple files

You can also use the `files.write()` method to write multiple files to the sandbox filesystem.

JavaScript & TypeScript

Python

```
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create()

const result = await sandbox.files.write([
{ path: '/tmp/test-file-1', data: 'file content 1' },
{ path: '/tmp/test-file-2', data: 'file content 2' }
])

console.log(result)

await sandbox.kill()
```

```
from novita_sandbox.code_interpreter import Sandbox

sandbox = Sandbox.create()

result = sandbox.files.write_files([
{ "path": "/tmp/test-file-1", "data": "file content 1" },
{ "path": "/tmp/test-file-2", "data": "file content 2" }
])
print(result)

sandbox.kill()
```

Last modified on June 4, 2026
